Skip to content

JS Wrapper | Remove CLI from the wrapper and download from S3 (AST-64803) #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 76 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
5fc39aa
delete git lfs
BenAlvo1 Sep 17, 2024
62f3865
check
BenAlvo1 Sep 17, 2024
2c79e5e
implement CxInstaller.ts
BenAlvo1 Sep 18, 2024
d386dc8
implement CxInstaller
BenAlvo1 Sep 18, 2024
a5bd34b
check linter
BenAlvo1 Sep 18, 2024
daf4b20
fix build errors
BenAlvo1 Sep 18, 2024
e7659e7
check
BenAlvo1 Sep 18, 2024
993cfa8
linter
BenAlvo1 Sep 18, 2024
db45191
linter
BenAlvo1 Sep 18, 2024
da5eefb
linter
BenAlvo1 Sep 18, 2024
1c86e61
check
BenAlvo1 Sep 18, 2024
c7c4ecc
fix download address
BenAlvo1 Sep 18, 2024
4ab87b1
check
BenAlvo1 Sep 18, 2024
61b323c
fix
BenAlvo1 Sep 18, 2024
ec4b6e4
fix console.error
BenAlvo1 Sep 18, 2024
ade6356
close file
BenAlvo1 Sep 18, 2024
6c4b05e
check
BenAlvo1 Sep 18, 2024
1ab52e0
check
BenAlvo1 Sep 18, 2024
a4443c5
check
BenAlvo1 Sep 18, 2024
f47b196
fixing
BenAlvo1 Sep 19, 2024
4f54f7c
refactor
BenAlvo1 Sep 22, 2024
2413f80
add logs to check
BenAlvo1 Sep 22, 2024
ada3729
check
BenAlvo1 Sep 22, 2024
38750f7
check
BenAlvo1 Sep 22, 2024
301d825
check
BenAlvo1 Sep 22, 2024
b0a9363
add logs
BenAlvo1 Sep 22, 2024
6465666
try add semaphore
BenAlvo1 Sep 22, 2024
0772395
Update executable path
BenAlvo1 Sep 22, 2024
3166236
fix exec path config
BenAlvo1 Sep 22, 2024
627a5e8
download zip to tmp dir
BenAlvo1 Sep 22, 2024
9f0b3e2
check chmod location
BenAlvo1 Sep 22, 2024
092b75f
add check.txt to resource
BenAlvo1 Sep 22, 2024
847fb8a
check
BenAlvo1 Sep 22, 2024
56bf079
remove download cli script
BenAlvo1 Sep 22, 2024
d3b9b28
refactor
BenAlvo1 Sep 22, 2024
86f8f8a
refactor
BenAlvo1 Sep 22, 2024
20a61b1
update package.json
BenAlvo1 Sep 22, 2024
20f935e
upgrade to node 16
BenAlvo1 Sep 22, 2024
1d611c9
refactor
BenAlvo1 Sep 22, 2024
964c90c
add delete zip file after extracted
BenAlvo1 Sep 23, 2024
e59cf25
optimize dependencies
BenAlvo1 Sep 23, 2024
7319800
remove unessecary dependency
BenAlvo1 Sep 23, 2024
33e97ce
fix
BenAlvo1 Sep 23, 2024
f8b0df2
re trigger scan
BenAlvo1 Sep 23, 2024
69460d4
retrigger cx scan
BenAlvo1 Sep 23, 2024
8349d1e
update cliDefaultVersion to 2.2.6
BenAlvo1 Sep 23, 2024
227bdaa
revert jest.config.js changes
BenAlvo1 Sep 23, 2024
46dc19d
revert test package.json data changes
BenAlvo1 Sep 23, 2024
4fdbc7d
added README.md to resource directory
BenAlvo1 Sep 23, 2024
17eda51
create resource dir if not exists
BenAlvo1 Sep 23, 2024
f6b9ac0
check
BenAlvo1 Sep 23, 2024
71723eb
fix
BenAlvo1 Sep 23, 2024
6bb1e64
set cli version
BenAlvo1 Sep 23, 2024
a6be1cc
include version file in package
BenAlvo1 Sep 23, 2024
6d0c28d
check
BenAlvo1 Sep 23, 2024
541d44e
Update update-cli.yml
BenAlvo1 Sep 23, 2024
12427d5
update github actions
BenAlvo1 Sep 23, 2024
81d3d09
fix package.json
BenAlvo1 Sep 23, 2024
57d1708
delete enter
BenAlvo1 Sep 23, 2024
bbf2bba
add commit sha
BenAlvo1 Sep 24, 2024
d0fb006
Update update-cli.yml
BenAlvo1 Sep 24, 2024
e1e2e83
added singleton and factory design patterns to CxWrapper
BenAlvo1 Sep 24, 2024
bde1814
delete unused set/get config
BenAlvo1 Sep 24, 2024
88a6161
refactor
BenAlvo1 Sep 24, 2024
1468265
remove uneeded semaphore from CxInstaller.ts
BenAlvo1 Sep 24, 2024
7b17b74
remove semaphore import
BenAlvo1 Sep 24, 2024
2a4c32d
added private and public to CxInstaller functions
BenAlvo1 Sep 24, 2024
6c37f42
make CxWrapper constructor private
BenAlvo1 Sep 24, 2024
0553d9e
added "multiple singleton" - one for each different scan configuratio…
BenAlvo1 Sep 24, 2024
a09505c
fix linter
BenAlvo1 Sep 24, 2024
4bf063b
resolve conversations
BenAlvo1 Sep 24, 2024
2388883
delete unecessery clone
BenAlvo1 Sep 24, 2024
6404d94
add comment
BenAlvo1 Sep 24, 2024
f6d7bf3
fix linter
BenAlvo1 Sep 24, 2024
a4cbc65
revert delete checkExecutableExists
BenAlvo1 Sep 24, 2024
18407b8
make CxWrapperFactory.ts interface and object
BenAlvo1 Sep 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitattributes

This file was deleted.

32 changes: 0 additions & 32 deletions .github/scripts/update_cli.sh

This file was deleted.

30 changes: 2 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: true

- name: Install Git LFS
run: |
sudo apt-get update
sudo apt-get install git-lfs
git lfs install

- name: Use Node.js 14
- name: Use Node.js 16
uses: actions/[email protected]
with:
node-version: 14
node-version: 16
registry-url: https://npm.pkg.github.com/
- run: npm ci
- name: Code Linting
run: npm run lint
- run: npm run build --if-present

- name: Check existence of cx-linux binary
run: |
if [ ! -f "src/main/wrapper/resources/cx-linux" ]; then
echo "cx-linux binary does not exist"; exit 1;
fi

- name: Check existence of cx.exe binary
run: |
if [ ! -f "src/main/wrapper/resources/cx.exe" ]; then
echo "cx.exe binary does not exist"; exit 1;
fi

- name: Check existence of cx-mac binary
run: |
if [ ! -f "src/main/wrapper/resources/cx-mac" ]; then
echo "cx-mac binary does not exist"; exit 1;
fi

- name: Run tests
env:
CX_CLIENT_ID: ${{ secrets.CX_CLIENT_ID}}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/delete-packages-and-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ jobs:

echo "Deleting all npm packages whose name ends with '-${{inputs.tag}}.0'"

VERSION_IDS=($(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/orgs/CheckmarxDev/packages/npm/ast-cli-javascript-wrapper/versions | jq '.[]|select(.name | contains("-${{inputs.tag}}.0"))|.id'))
VERSION_IDS=($(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/orgs/CheckmarxDev/packages/npm/ast-cli-javascript-wrapper-runtime-cli/versions | jq '.[]|select(.name | contains("-${{inputs.tag}}.0"))|.id'))

for versionId in "${VERSION_IDS[@]}"
do
echo "Deleting version $versionId..."
curl -L -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/orgs/CheckmarxDev/packages/npm/ast-cli-javascript-wrapper/versions/$versionId"
curl -L -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/orgs/CheckmarxDev/packages/npm/ast-cli-javascript-wrapper-runtime-cli/versions/$versionId"
echo "Version $versionId deleted successfully!"
done

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ on:

jobs:
nightly:
uses: CheckmarxDev/ast-cli-javascript-wrapper/.github/workflows/release.yml@main
uses: CheckmarxDev/ast-cli-javascript-wrapper-runtime-cli/.github/workflows/release.yml@main
secrets: inherit
11 changes: 1 addition & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ permissions:

jobs:
delete:
uses: CheckmarxDev/ast-cli-javascript-wrapper/.github/workflows/delete-packages-and-releases.yml@main
uses: CheckmarxDev/ast-cli-javascript-wrapper-runtime-cli/.github/workflows/delete-packages-and-releases.yml@main
with:
tag: ${{ inputs.jsTag }}
secrets: inherit
Expand All @@ -58,7 +58,6 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true # Ensure LFS files are checked out

# GIT CONFIGURATION
- run: |
Expand All @@ -80,14 +79,6 @@ jobs:
echo "TAG_NAME=$(npm version patch --no-git-tag-version)" >> $GITHUB_ENV
fi

# DOWNLOAD CLI IF IT IS A DEV VERSION AND A CLI TAG WAS PROVIDED
- name: Download cli with tag ${{ inputs.cliTag }}
if: inputs.dev == true && inputs.cliTag != ''
run: |
# Update binaries
chmod +x ./.github/scripts/update_cli.sh
./.github/scripts/update_cli.sh ${{ inputs.cliTag }}

# RUN NPM INSTALL AND BUILD
- name: NPM ci and build
run: |
Expand Down
58 changes: 26 additions & 32 deletions .github/workflows/update-cli.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,53 @@
name: Update checkmarx ast cli
name: Update Checkmarx AST CLI

on:
workflow_dispatch:
inputs:
new_cli_version:
description: 'New CLI version (optional)'
required: false
schedule:
- cron: '0 0 * * *'

jobs:
update-checkmarx-cli:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
lfs: true

- name: Install Git LFS
run: |
sudo apt-get update
sudo apt-get install git-lfs
git lfs install

- name: Configure Git user
run: |
git config --global user.name github-actions
git config --global user.email [email protected]

# Fetch the latest Checkmarx AST CLI version
- name: Get Latest Checkmarx API version
id: checkmarx-ast-cli
run: |
echo ::set-output name=release_tag::$(curl -sL https://api.github.com/repos/Checkmarx/ast-cli/releases/latest | jq -r ".tag_name")
echo ::set-output name=current_tag::$(<checkmarx-ast-cli.version)
if [ "${{ github.event.inputs.new_cli_version }}" ]; then
LATEST_VERSION=${{ github.event.inputs.new_cli_version }}
else
LATEST_VERSION=$(curl -sL https://api.github.com/repos/Checkmarx/ast-cli/releases/latest | jq -r ".tag_name")
fi
CURRENT_VERSION=$(<checkmarx-ast-cli.version)
echo ::set-output name=release_tag::$LATEST_VERSION
echo ::set-output name=current_tag::$CURRENT_VERSION

- name: Update Checkmarx cli version
# Update the version file if the latest version differs
- name: Update Checkmarx CLI version in version file
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
env:
RELEASE_TAG: ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
run: |
# Update current release
echo ${{ steps.checkmarx-ast-cli.outputs.release_tag }} > checkmarx-ast-cli.version

- name: Download latest cli and update branch
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
run: |
# Update binaries
chmod +x ./.github/scripts/update_cli.sh
./.github/scripts/update_cli.sh ${{ steps.checkmarx-ast-cli.outputs.release_tag }}

- name: Track large files with Git LFS
# Update the TypeScript file's cliDefaultVersion field
- name: Update cliDefaultVersion in CxInstaller.ts
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
env:
NEW_CLI_VERSION: ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
run: |
git lfs track "src/main/wrapper/resources/cx-linux"
git lfs track "src/main/wrapper/resources/cx.exe"
git lfs track "src/main/wrapper/resources/cx-mac"
git add .gitattributes
git add src/main/wrapper/resources/cx-linux src/main/wrapper/resources/cx.exe src/main/wrapper/resources/cx-mac
git commit -m "Track Checkmarx CLI binaries with Git LFS"
FILE_PATH="src/main/osinstaller/CxInstaller.ts"
# Ensure that 'cliDefaultVersion' is updated correctly
sed -i "s/\(cliDefaultVersion = '\)[^']*\(';\)/\1${NEW_CLI_VERSION}\2/" $FILE_PATH

# Create a Pull Request with the version changes
- name: Create Pull Request
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c #v6
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<img src="./logo.png" alt="Logo" width="80" height="80">
</a>

<h3 align="center">AST-CLI-JAVASCRIPT-WRAPPER</h3>
<h3 align="center">AST-CLI-JAVASCRIPT-WRAPPER-RUNTIME-CLI</h3>

<!-- TABLE OF CONTENTS -->
<details open="open">
Expand Down Expand Up @@ -40,7 +40,7 @@ Add the following dependency:

```
"dependencies": {
"@checkmarxdev/ast-cli-javascript-wrapper": "{version}"
"@checkmarxdev/ast-cli-javascript-wrapper-runtime-cli": "{version}"
}
```

Expand Down Expand Up @@ -86,7 +86,7 @@ setx PATH_TO_EXECUTABLE {value}

Checkmarx - AST Integrations Team

CxProject Link: [https://github.com/CheckmarxDev/ast-cli-javascript-wrapper](https://github.com/CheckmarxDev/ast-cli-javascript-wrapper)
CxProject Link: [https://github.com/CheckmarxDev/ast-cli-javascript-wrapper-runtime-cli](https://github.com/CheckmarxDev/ast-cli-javascript-wrapper-runtime-cli)


© 2021 Checkmarx Ltd. All Rights Reserved.
2 changes: 1 addition & 1 deletion checkmarx-ast-cli.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.6
2.2.5
Loading