Skip to content

Commit

Permalink
Improved logic to invoke php-parse (#108)
Browse files Browse the repository at this point in the history
* Improved logic to invoke php-parse

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>

* Added php repo tests. Fix php parser version

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>


---------

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
  • Loading branch information
prabhu authored Jan 9, 2024
1 parent 1af339d commit 098c8c0
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 56 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
contents: write
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
Expand Down
35 changes: 20 additions & 15 deletions .github/workflows/nodejstests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ jobs:
node-version: ['20.x']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'ShiftLeftSecurity/shiftleft-java-example'
path: 'repotests/shiftleft-java-example'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'juice-shop/juice-shop'
path: 'repotests/juice-shop'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'ShiftLeftSecurity/shiftleft-ts-example'
path: 'repotests/shiftleft-ts-example'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'libexpat/libexpat'
path: 'repotests/libexpat'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'HooliCorp/DjanGoat'
path: 'repotests/DjanGoat'
- uses: coursier/cache-action@v6
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ matrix.java-version }}
Expand All @@ -64,34 +64,34 @@ jobs:
java-version: ['17', '19', '20', '21']
node-version: ['20.x']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'ShiftLeftSecurity/shiftleft-java-example'
path: 'repotests/shiftleft-java-example'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'juice-shop/juice-shop'
path: 'repotests/juice-shop'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'ShiftLeftSecurity/shiftleft-ts-example'
path: 'repotests/shiftleft-ts-example'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'libexpat/libexpat'
path: 'repotests/libexpat'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'HooliCorp/DjanGoat'
path: 'repotests/DjanGoat'
- uses: coursier/cache-action@v6
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ matrix.java-version }}
Expand All @@ -100,10 +100,15 @@ jobs:
run: |
sbt stage createDistribution
cd wrapper\\nodejs
.\build.ps1
copy ..\..\target\atom.zip plugins\
Expand-Archive -Path ..\..\target\atom.zip -DestinationPath plugins\ -Force
Remove-Item -Force plugins\atom.zip
php --php-ini php.ini composer.phar require nikic/php-parser:4.18.0 --ignore-platform-reqs --optimize-autoloader
npm install
npm install -g .
get-command atom
get-command astgen
get-command phpastgen
astgen --version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/npm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
packages: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: https://registry.npmjs.org/
- uses: coursier/cache-action@v6
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '19'
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@ jobs:
testing:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'ShiftLeftSecurity/shiftleft-java-example'
path: 'repotests/shiftleft-java-example'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'juice-shop/juice-shop'
path: 'repotests/juice-shop'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'ShiftLeftSecurity/shiftleft-ts-example'
path: 'repotests/shiftleft-ts-example'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'libexpat/libexpat'
path: 'repotests/libexpat'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'HooliCorp/DjanGoat'
path: 'repotests/DjanGoat'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'DefectDojo/django-DefectDojo'
path: 'repotests/django-DefectDojo'
- uses: coursier/cache-action@v6
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
contents: write
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: coursier/cache-action@v6
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
Expand Down
41 changes: 24 additions & 17 deletions .github/workflows/repotests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,32 @@ jobs:
java-version: [ '21' ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'HooliCorp/java-sec-code'
path: 'repotests/java-sec-code'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'DefectDojo/django-DefectDojo'
path: 'repotests/django-DefectDojo'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'nodejs/node'
path: 'repotests/nodejs'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'awsdocs/aws-doc-sdk-examples'
path: 'repotests/aws-doc-sdk-examples'
- uses: actions/checkout@v4
with:
repository: 'friendica/friendica'
path: 'repotests/friendica'
- uses: coursier/cache-action@v6
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ matrix.java-version }}
Expand All @@ -53,6 +57,9 @@ jobs:
./atom.sh usages --remove-atom -o /tmp/v8.atom -l h $GITHUB_WORKSPACE/repotests/nodejs/deps/v8 -Dlog4j.configurationFile=log4j2.xml --slice-outfile /tmp/v8.slices.json
./atom.sh usages --remove-atom -o /tmp/uv.atom -l h $GITHUB_WORKSPACE/repotests/nodejs/deps/uv -Dlog4j.configurationFile=log4j2.xml --slice-outfile /tmp/uv.slices.json
./atom.sh usages --remove-atom -o /tmp/aws.atom -l h $GITHUB_WORKSPACE/repotests/aws-doc-sdk-examples/cpp -Dlog4j.configurationFile=log4j2.xml --slice-outfile /tmp/aws.slices.json
./atom.sh usages --remove-atom -o /tmp/friendica.atom -l h $GITHUB_WORKSPACE/repotests/friendica -Dlog4j.configurationFile=log4j2.xml --slice-outfile /tmp/friend.slices.json
cdxgen -t php -o $GITHUB_WORKSPACE/repotests/friendica/bom.json $GITHUB_WORKSPACE/repotests/friendica
./atom.sh reachables --remove-atom -o /tmp/friendica2.atom -l h $GITHUB_WORKSPACE/repotests/friendica -Dlog4j.configurationFile=log4j2.xml --slice-outfile /tmp/friend2.slices.json
env:
JAVA_TOOL_OPTIONS: "-Dfile.encoding=UTF-8"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -63,48 +70,48 @@ jobs:
java-version: ['17', '19', '20']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'ShiftLeftSecurity/shiftleft-java-example'
path: 'repotests/shiftleft-java-example'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'juice-shop/juice-shop'
path: 'repotests/juice-shop'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'ShiftLeftSecurity/shiftleft-ts-example'
path: 'repotests/shiftleft-ts-example'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'libexpat/libexpat'
path: 'repotests/libexpat'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'HooliCorp/java-sec-code'
path: 'repotests/java-sec-code'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'HooliCorp/DjanGoat'
path: 'repotests/DjanGoat'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'DefectDojo/django-DefectDojo'
path: 'repotests/django-DefectDojo'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'nodejs/node'
path: 'repotests/nodejs'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'awsdocs/aws-doc-sdk-examples'
path: 'repotests/aws-doc-sdk-examples'
- uses: coursier/cache-action@v6
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ matrix.java-version }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ docker run --rm -v /tmp:/tmp -v $HOME:$HOME -v $(pwd):/app:rw -it ghcr.io/appthr
- JavaScript
- TypeScript
- Python
- PHP
- PHP (Requires PHP >= 7.0. Supports PHP 5.2 to 8.3)

## Atom Specification

Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name := "atom"
ThisBuild / organization := "io.appthreat"
ThisBuild / version := "1.8.1"
ThisBuild / version := "1.8.2"
ThisBuild / scalaVersion := "3.3.1"

val chenVersion = "1.1.3"
val chenVersion = "1.1.4"

lazy val atom = Projects.atom

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/atom",
"issueTracker": "https://github.com/AppThreat/atom/issues",
"name": "atom",
"version": "1.8.1",
"version": "1.8.2",
"description": "Atom is a novel intermediate representation for next-generation code analysis.",
"applicationCategory": "code-analysis",
"keywords": [
Expand Down
14 changes: 13 additions & 1 deletion wrapper/nodejs/build.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
copy ..\..\target\atom.zip plugins\
Expand-Archive -Path ..\..\target\atom.zip -DestinationPath plugins\ -Force
Remove-Item plugins\atom.zip
Remove-Item -Force plugins\atom.zip

php --php-ini php.ini -r "copy('http://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php --php-ini php.ini composer-setup.php
php -r "unlink('composer-setup.php');"
$env:COMPOSER_VENDOR_DIR="plugins"
php --php-ini php.ini composer.phar require nikic/php-parser:4.18.0 --ignore-platform-reqs --optimize-autoloader

npm install

Remove-Item -Force composer.phar
Remove-Item -Force composer.json
Remove-Item -Force composer.lock
2 changes: 1 addition & 1 deletion wrapper/nodejs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ php -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff0319065
php composer-setup.php
php -r "unlink('composer-setup.php');"
export COMPOSER_VENDOR_DIR=plugins
php composer.phar require nikic/php-parser --ignore-platform-reqs --optimize-autoloader
php composer.phar require nikic/php-parser:4.18.0 --ignore-platform-reqs --optimize-autoloader

npm install

Expand Down
4 changes: 2 additions & 2 deletions wrapper/nodejs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wrapper/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@appthreat/atom",
"version": "1.8.1",
"version": "1.8.2",
"description": "Create atom (⚛) representation for your application, packages and libraries",
"exports": "./index.js",
"type": "module",
Expand Down
2 changes: 2 additions & 0 deletions wrapper/nodejs/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extension=openssl
extension=zip
Loading

0 comments on commit 098c8c0

Please sign in to comment.