Skip to content

Commit

Permalink
php2atom with php-parser (#47)
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu authored Dec 22, 2023
1 parent 5d32fe8 commit c2f9ada
Show file tree
Hide file tree
Showing 65 changed files with 10,980 additions and 198 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ platform/workspace
**/astgen-macos
**/astgen-macos-arm
**/astgen-linux
**/php2cpg/bin
**/php2atom/bin
**/php2atom/vendor
/foo.c
/woo.c
.DS_Store
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ jobs:
with:
distribution: 'zulu'
java-version: '21'
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.3"
tools: composer:v2
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
with:
distribution: 'zulu'
java-version: '21'
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.3"
tools: composer:v2
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -44,6 +50,7 @@ jobs:
if: runner.os == 'macOS'
- name: Install and test
run: |
bash ./platform/frontends/php2atom/install.sh
npm install -g @appthreat/atom
python3.11 -m pip install --upgrade pip
python3.11 -m pip install poetry
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
with:
distribution: 'zulu'
java-version: ${{ matrix.jvm }}
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.3"
tools: composer:v2
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -44,6 +50,7 @@ jobs:
if: runner.os == 'macOS'
- name: Install and test
run: |
bash ./platform/frontends/php2atom/install.sh
npm install -g @appthreat/atom
python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install poetry
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ jobs:
with:
distribution: 'zulu'
java-version: '21'
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.3"
tools: composer:v2
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ null
**/astgen-macos
**/astgen-macos-arm
**/astgen-linux
**/php2cpg/bin
**/php2atom/bin
**/php2atom/vendor
/foo.c
/woo.c
/cpg_*.bin.zip
Expand Down
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "chen"
ThisBuild / organization := "io.appthreat"
ThisBuild / version := "1.1.2"
ThisBuild / version := "1.1.3"
ThisBuild / scalaVersion := "3.3.1"

val cpgVersion = "1.4.22"
Expand All @@ -16,6 +16,7 @@ lazy val pysrc2cpg = Projects.pysrc2cpg
lazy val jssrc2cpg = Projects.jssrc2cpg
lazy val javasrc2cpg = Projects.javasrc2cpg
lazy val jimple2cpg = Projects.jimple2cpg
lazy val php2atom = Projects.php2atom

lazy val aggregatedProjects: Seq[ProjectReference] = Seq(
platform,
Expand All @@ -29,6 +30,7 @@ lazy val aggregatedProjects: Seq[ProjectReference] = Seq(
jssrc2cpg,
javasrc2cpg,
jimple2cpg,
php2atom
)

ThisBuild / libraryDependencies ++= Seq(
Expand Down
13 changes: 10 additions & 3 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ ENV JAVA_VERSION=$JAVA_VERSION \
CHEN_DATAFLOW_TRACKED_WIDTH=128 \
SCALAPY_PYTHON_LIBRARY=python3.11 \
ANDROID_HOME=/opt/android-sdk-linux \
CHEN_INSTALL_DIR=/opt/workspace
CHEN_INSTALL_DIR=/opt/workspace \
PHP_PARSER_BIN=/opt/vendor/bin/php-parse \
COMPOSER_ALLOW_SUPERUSER=1
ENV PATH=/opt/miniconda3/bin:${PATH}:/opt/platform:${JAVA_HOME}/bin:${MAVEN_HOME}/bin:${GRADLE_HOME}/bin:/usr/local/bin/:/root/.local/bin:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools:

WORKDIR /opt
COPY ./ci/conda-install.sh /opt/
COPY README.md /opt/
COPY ./platform/frontends/php2atom/composer.json /opt/composer.json
COPY ./platform/frontends/php2atom/composer.json /opt/composer.lock

RUN set -e; \
ARCH_NAME="$(rpm --eval '%{_arch}')"; \
Expand All @@ -51,7 +55,7 @@ RUN set -e; \
*) echo >&2 "error: unsupported architecture: '$ARCH_NAME'"; exit 1 ;; \
esac; \
echo -e "[nodejs]\nname=nodejs\nstream=20\nprofiles=\nstate=enabled\n" > /etc/dnf/modules.d/nodejs.module \
&& microdnf install -y gcc git-core wget bash graphviz graphviz-gd \
&& microdnf install -y gcc git-core php php-cli php-curl php-zip php-bcmath php-json php-pear php-mbstring php-devel make wget bash graphviz graphviz-gd \
pcre2 findutils which tar gzip zip unzip sudo nodejs ncurses sqlite-devel glibc-common glibc-all-langpacks \
&& mkdir -p /opt/miniconda3 /opt/workspace \
&& wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /opt/miniconda3/miniconda.sh \
Expand Down Expand Up @@ -87,7 +91,9 @@ RUN set -e; \
&& /opt/android-sdk-linux/cmdline-tools/latest/bin/sdkmanager 'platform-tools' --sdk_root=/opt/android-sdk-linux \
&& /opt/android-sdk-linux/cmdline-tools/latest/bin/sdkmanager 'platforms;android-33' --sdk_root=/opt/android-sdk-linux \
&& /opt/android-sdk-linux/cmdline-tools/latest/bin/sdkmanager 'build-tools;33.0.0' --sdk_root=/opt/android-sdk-linux \
&& sudo npm install -g @appthreat/atom @cyclonedx/cdxgen --omit=optional
&& sudo npm install -g @appthreat/atom @cyclonedx/cdxgen --omit=optional \
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && php composer-setup.php \
&& mv composer.phar /usr/local/bin/composer
ENV LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 \
Expand All @@ -97,6 +103,7 @@ COPY ./pyproject.toml /opt/
COPY ./target/chen.zip .
COPY ./notebooks /opt/notebooks
RUN unzip -q chen.zip \
&& composer update --no-progress --prefer-dist --ignore-platform-reqs \
&& python -m pip install --no-deps . \
&& rm chen.zip conda-install.sh pyproject.toml \
&& microdnf clean all
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"downloadUrl": "https://github.com/AppThreat/chen",
"issueTracker": "https://github.com/AppThreat/chen/issues",
"name": "chen",
"version": "1.1.2",
"version": "1.1.3",
"description": "Code Hierarchy Exploration Net (chen) is an advanced exploration toolkit for your application source code and its dependency hierarchy.",
"applicationCategory": "code-analysis",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = "1.1.2" %}
{% set version = "1.1.3" %}

package:
name: chen
Expand Down
38 changes: 0 additions & 38 deletions platform/frontends/c2cpg/README.md

This file was deleted.

54 changes: 0 additions & 54 deletions platform/frontends/javasrc2cpg/README.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class ConfigFileCreationPass(cpg: Cpg) extends XConfigFileCreationPass(cpg):
// Bom
pathEndFilter("bom.json"),
pathEndFilter(".cdx.json"),
pathEndFilter("chennai.json")
pathEndFilter("chennai.json"),
extensionFilter(".yml"),
extensionFilter(".yaml")
)

private def mybatisFilter(file: File): Boolean =
Expand Down
37 changes: 0 additions & 37 deletions platform/frontends/jimple2cpg/README.md

This file was deleted.

49 changes: 0 additions & 49 deletions platform/frontends/jssrc2cpg/README.md

This file was deleted.

26 changes: 26 additions & 0 deletions platform/frontends/php2atom/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name := "php2atom"

dependsOn(Projects.dataflowengineoss, Projects.x2cpg % "compile->compile;test->test")

libraryDependencies ++= Seq(
"com.lihaoyi" %% "upickle" % Versions.upickle,
"com.lihaoyi" %% "ujson" % Versions.upickle,
"io.shiftleft" %% "codepropertygraph" % Versions.cpg,
"org.scalatest" %% "scalatest" % Versions.scalatest % Test,
"io.circe" %% "circe-core" % Versions.circe
)

enablePlugins(JavaAppPackaging, LauncherJarPlugin)
Global / onChangedBuildSource := ReloadOnSourceChanges
Universal / packageName := name.value
Universal / topLevelDirectory := None

githubOwner := "appthreat"
githubRepository := "chen"
credentials +=
Credentials(
"GitHub Package Registry",
"maven.pkg.github.com",
"appthreat",
sys.env.getOrElse("GITHUB_TOKEN", "N/A")
)
Loading

0 comments on commit c2f9ada

Please sign in to comment.