appthreat-chen

Code Hierarchy Exploration Net (chen)

https://github.com/appthreat/chen

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.6%) to scientific vocabulary

Keywords

code-analysis code-hierarchy-representation dependency-analysis
Last synced: 6 months ago · JSON representation

Repository

Code Hierarchy Exploration Net (chen)

Basic Info
  • Host: GitHub
  • Owner: AppThreat
  • License: apache-2.0
  • Language: Scala
  • Default Branch: main
  • Homepage: https://appthreat.com
  • Size: 27 MB
Statistics
  • Stars: 21
  • Watchers: 4
  • Forks: 2
  • Open Issues: 19
  • Releases: 90
Topics
code-analysis code-hierarchy-representation dependency-analysis
Created over 2 years ago · Last pushed 6 months ago
Metadata Files
Readme License Support Codemeta

README.md

chen

Code Hierarchy Exploration Net (chen) is an advanced exploration toolkit for your application source code and its dependency hierarchy. This repo contains the source code for chen library and an advanced REPL console called chennai (chen not AI).

Requirements

  • Java >= 21
  • Python >= 3.10
  • Node.js >= 20 (To run atom)
  • Minimum 16GB RAM

Getting started

chen container image has everything needed to get started.

Jupyter notebook with docker compose

Use the docker compose from this repo to try chennai with Jupyter Notebook.

shell git clone https://github.com/AppThreat/chen cd chen docker compose up

  • Navigate to the link "http://127.0.0.1:9999/tree?token=chennai"
  • Click notebooks and then getting-started.ipynb

Use the controls in Jupyter to interact with the cells. For a preview via github click here

Jupyter console Jupyter console

Interactive console

To start the interactive console, run chennai command.

shell docker run --rm -v /tmp:/tmp -v $HOME:$HOME -v $(pwd):/app:rw -it ghcr.io/appthreat/chen chennai

Chennai server mode

chennai could also be run as an HTTP server.

shell docker run --rm -v /tmp:/tmp -v $HOME:$HOME -v $(pwd):/app:rw -p 8080:8080 -it ghcr.io/appthreat/chen chennai --server

Defaults:

  • Port 8080
  • Username chenadmin
  • Password chenpassword

Local Installation

```shell

Install atom and cdxgen

sudo npm install -g @appthreat/atom @cyclonedx/cdxgen --omit=optional

Install chen from pypi

pip install appthreat-chen ```

To download the chen distribution.

shell chen --download

To generate custom graphs and models with atom for data science, download the scientific pack which installs support for the PyTorch ecosystem. conda is recommended for the best experience.

shell chen --download --with-science

Once the download finishes, the command will display the download location along with the environment variables that need to be set to invoke chennai console. Example output below:

shell [21:53:36] INFO To run chennai console, add the following environment variables to your .zshrc or .bashrc: export JAVA_OPTS="-Xmx16G" export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF-8 -Djna.library.path=<lib dir>" export SCALAPY_PYTHON_LIBRARY=python3.12 export CHEN_HOME=/home/user/.local/share/chen export PATH=$PATH:/home/user/.local/share/chen/platform:/home/user/.local/share/chen/platform/bin:

It is important to set these environment variables without which the console commands would fail with errors.

Running the console

Type chennai to launch the console.

shell chennai

```shell


/ |_ _ ._ ._ . o | / \ / \ / \ / || _ | | (/_ | | | | (| | |) _/ _/ _/ / |

Version: 0.0.7 Type help to begin

chennai> ```

Sample commmands

Help command

```shell chennai> help val res0: Helper = Welcome to the interactive help system. Below you find a table of all available top-level commands. To get more detailed help on a specific command, just type

help.<command>.

Try help.importCode to begin with.


command | description | example | =============================================================================================================================================================| annotations | List annotations | annotations | callTree | Show call tree for the given method | callTree(method full name) | close | Close project by name | close(projectName) | declarations | List declarations | declarations | distance | Show graph edit distance from the source method to the comparison methods | distance(source method iterator, comparison method iterators) | exit | Exit the REPL | | files | List files | files | importAtom | Create new project from existing atom | importAtom("app.atom") | importCode | Create new project from code | importCode("example.jar") | imports | List imports | imports | methods | List methods | methods('Methods', includeCalls=true, tree=true) | sensitive | List sensitive literals | sensitive | showSimilar | Show methods similar to the given method | showSimilar(method full name) | summary | Display summary information | summary | reachables | Show reachable flows from a source to sink. Default source: framework-input and sink: framework-output | reachables | cryptos | Show reachable flows from a source to sink. Default source: crypto-algorithm and sink: crypto-generate | cryptos | ```

Refer to the documentation site to learn more about the commands.

Languages supported

  • C/C++
  • H (C/C++ Header files alone)
  • Java (Requires compilation) - 8 to 21
  • Jar
  • Android APK (Requires Android SDK. Set the environment variable ANDROID_HOME)
  • JavaScript
  • TypeScript
  • Python
  • PHP (Requires PHP >= 7.0. Supports PHP 5.2 to 8.3)
  • Ruby (Requires Ruby >= 3.4.0. Supports Ruby 1.8 - 3.3 syntax)

Troubleshooing

Commands throw errors in chennai console

You might see errors like this in chennai console.

``shell chennai> help -- [E006] Not Found Error: ----------------------------------------------------- 1 |help |^^^^ |Not found: help |----------------------------------------------------------------------------- | Explanation (enabled by-explain) |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | The identifier forhelpis not bound, that is, | no declaration for this identifier can be found. | That can happen, for example, ifhelp` or its declaration has either been | misspelt or if an import is missing.


1 error found ```

This error is mostly due to missing python .so (linux), .dll (windows) or .dylib (mac) file. Ensure the environment variables below are set correctly.

  • SCALAPYPYTHONLIBRARY - Use values such as python3.10, python3.11 based on the version installed. On Windows, there are no dots. Eg: python312
  • JAVATOOLOPTIONS - jna.library.path must be set to the python lib directory
  • SCALAPYPYTHONPROGRAMNAME - Path to Python executable in case of virtual environments (Usually not required)

Origin of chen

chen is a fork of the popular joern project. We deviate from the joern project in the following ways:

  • Keep the CPG implementation at 1.0 based on the original paper.
  • Make code analysis accessible by adding first-class integration with Python and frameworks such as NetworkX and PyTorch.
  • Enable broader hierarchical analysis (Application + Dependency + Container + OS layer + Cloud + beyond)

We don't intend for bug-to-bug compatibility and often rewrite patches to suit our needs. We also do not bring features and passes that do not add value for hierarchical analysis.

License

Apache-2.0

Enterprise support

Enterprise support including custom language development and integration services is available via AppThreat Ltd.

Sponsors

YourKit supports open source projects with innovative and intelligent tools for monitoring and profiling Java and .NET applications. YourKit is the creator of YourKit Java Profiler, YourKit .NET Profiler, and YourKit YouMonitor.

YourKit logo

Owner

  • Name: AppThreat
  • Login: AppThreat
  • Kind: organization
  • Email: hello@appthreat.com
  • Location: United Kingdom

Empower your devs.

CodeMeta (codemeta.json)

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "@type": "SoftwareSourceCode",
  "license": "https://spdx.org/licenses/Apache-2.0",
  "codeRepository": "git+https://github.com/AppThreat/chen.git",
  "contIntegration": "https://github.com/AppThreat/chen/actions",
  "downloadUrl": "https://github.com/AppThreat/chen",
  "issueTracker": "https://github.com/AppThreat/chen/issues",
  "name": "chen",
  "version": "2.5.5",
  "description": "Code Hierarchy Exploration Net (chen) is an advanced exploration toolkit for your application source code and its dependency hierarchy.",
  "applicationCategory": "code-analysis",
  "keywords": [
    "static-analysis",
    "code-analysis",
    "dependency-analysis",
    "code-hierarchy-analysis"
  ],
  "programmingLanguage": [
    "Scala 3",
    "Node.js",
    "Python 3"
  ],
  "runtimePlatform": [
    "JVM",
    "Python 3"
  ],
  "operatingSystem": [
    "Linux",
    "Windows",
    "MacOS"
  ],
  "softwareRequirements": [
    "Python >= 3.10",
    "Java >= 21"
  ],
  "author": [
    {
      "@type": "Person",
      "givenName": "Team",
      "familyName": "AppThreat",
      "email": "cloud@appthreat.com"
    }
  ]
}

GitHub Events

Total
  • Create event: 42
  • Issues event: 8
  • Release event: 20
  • Watch event: 5
  • Delete event: 22
  • Issue comment event: 10
  • Push event: 87
  • Pull request review comment event: 13
  • Pull request review event: 13
  • Pull request event: 48
Last Year
  • Create event: 42
  • Issues event: 8
  • Release event: 20
  • Watch event: 5
  • Delete event: 22
  • Issue comment event: 10
  • Push event: 87
  • Pull request review comment event: 13
  • Pull request review event: 13
  • Pull request event: 48

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 10
  • Total pull requests: 37
  • Average time to close issues: about 11 hours
  • Average time to close pull requests: about 5 hours
  • Total issue authors: 1
  • Total pull request authors: 2
  • Average comments per issue: 0.1
  • Average comments per pull request: 0.14
  • Merged pull requests: 28
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 7
  • Pull requests: 27
  • Average time to close issues: about 18 hours
  • Average time to close pull requests: about 2 hours
  • Issue authors: 1
  • Pull request authors: 2
  • Average comments per issue: 0.14
  • Average comments per pull request: 0.19
  • Merged pull requests: 18
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • prabhu (13)
Pull Request Authors
  • prabhu (45)
  • malice00 (1)
Top Labels
Issue Labels
enhancement (1)
Pull Request Labels
sponsored (5) ruby (4) python (4) scala (2) security (1) enhancement (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 1,205 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 80
  • Total maintainers: 1
pypi.org: appthreat-chen

Code Hierarchy Exploration Net (chen)

  • Versions: 80
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1,205 Last month
Rankings
Dependent packages count: 7.4%
Forks count: 30.0%
Average: 36.2%
Stargazers count: 38.9%
Dependent repos count: 68.7%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/containers.yml actions
  • actions/checkout v3 composite
  • actions/setup-java v3 composite
  • docker/build-push-action v4 composite
  • docker/login-action v2 composite
  • docker/metadata-action v4 composite
  • docker/setup-buildx-action v2 composite
  • docker/setup-qemu-action v2 composite
.github/workflows/master.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-java v3 composite
.github/workflows/pr.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-java v3 composite
.github/workflows/release.yml actions
  • actions/checkout v3 composite
  • actions/setup-java v3 composite
  • softprops/action-gh-release v1 composite
ci/Dockerfile docker
  • almalinux 9.2-minimal build
platform/frontends/javasrc2cpg/src/test/resources/config_tests/build.gradle maven
platform/frontends/javasrc2cpg/src/test/resources/config_tests/build.gradle.kts maven
poetry.lock pypi
  • 111 dependencies
pyproject.toml pypi
  • appdirs ^1.4.4
  • gitpython ^3.1.37
  • httpx ^0.24.1
  • oras ^0.1.24
  • orjson ^3.9.0
  • packageurl-python ^0.11.2
  • psutil ^5.9.5
  • python >=3.8.1,<3.12
  • quart ^0.18.4
  • rich ^13.4.1
  • uvloop ^0.17.0
  • websockets ^11.0.2
.github/workflows/win_compat.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v4 composite
docker-compose.yml docker
  • ghcr.io/appthreat/chen latest