Skip to content

Commit

Permalink
Support cx-linux-arm aka running om Mac Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
tsemachh committed Jan 12, 2025
1 parent 49ea290 commit a04b032
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
src/main/resources/cx-linux filter=lfs diff=lfs merge=lfs -text
src/main/resources/cx-linux-arm filter=lfs diff=lfs merge=lfs -text
src/main/resources/cx.exe filter=lfs diff=lfs merge=lfs -text
src/main/resources/cx-mac filter=lfs diff=lfs merge=lfs -text
10 changes: 10 additions & 0 deletions .github/scripts/update_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
release=$1
filename_windows=ast-cli_${release}_windows_x64.zip
filename_linux=ast-cli_${release}_linux_x64.tar.gz
filename_linuxarm=ast-cli_${release}_linux_arm64.tar.gz
filename_darwin=ast-cli_${release}_darwin_x64.tar.gz

#Windows
Expand All @@ -22,6 +23,15 @@ mv ./tmp/cx ./src/main/resources/cx-linux
rm -r tmp
rm ${filename_linux}

#linuxarm
echo "Updating linuxarm binary"
wget https://github.com/checkmarx/ast-cli/releases/download/${release}/${filename_linuxarm}
mkdir ./tmp/
tar -xvzf ${filename_linuxarm} -C ./tmp/
mv ./tmp/cx ./src/main/resources/cx-linux-arm
rm -r tmp
rm ${filename_linuxarm}

#darwin
echo "Updating mac binary"
wget https://github.com/checkmarx/ast-cli/releases/download/${release}/${filename_darwin}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ jobs:
if [ ! -f "src/main/resources/cx-linux" ]; then
echo "cx-linux binary does not exist"; exit 1;
fi
- name: Check existence of cx-linux-arm binary
run: |
if [ ! -f "src/main/resources/cx-linux-arm" ]; then
echo "cx-linux-arm binary does not exist"; exit 1;
fi
- name: Check existence of cx.exe binary
run: |
if [ ! -f "src/main/resources/cx.exe" ]; then
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/update-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ jobs:
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
run: |
git lfs track "src/main/resources/cx-linux"
git lfs track "src/main/resources/cx-linux-arm"
git lfs track "src/main/resources/cx.exe"
git lfs track "src/main/resources/cx-mac"
git add .gitattributes
git add src/main/resources/cx-linux src/main/resources/cx.exe src/main/resources/cx-mac
git add src/main/resources/cx-linux src/main/resources/cx-linux-arm src/main/resources/cx.exe src/main/resources/cx-mac
git commit -m "Track Checkmarx CLI binaries with Git LFS"
- name: Create Pull Request
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/com/checkmarx/ast/wrapper/Execution.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private Execution() {
private static final String OS_WINDOWS = "windows";
private static final List<String> OS_MAC = Arrays.asList("mac os x", "darwin", "osx");
private static final String FILE_NAME_LINUX = "cx-linux";
private static final String FILE_NAME_LINUX_ARM = "cx-linux-arm";
private static final String FILE_NAME_MAC = "cx-mac";
private static final String FILE_NAME_WINDOWS = "cx.exe";
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
Expand Down Expand Up @@ -143,15 +144,21 @@ private static Process buildProcess(List<String> commands) throws IOException {
}

private static String detectBinaryName() {
String arch = OS_NAME;
String osName = OS_NAME;
String osArch = System.getProperty("os.arch").toLowerCase(Locale.ENGLISH);
String fileName = null;
if (arch.contains(OS_LINUX)) {
fileName = FILE_NAME_LINUX;
} else if (arch.contains(OS_WINDOWS)) {

if (osName.contains(OS_LINUX)) {
if (osArch.contains("arm") || osArch.contains("aarch64")) {
fileName = FILE_NAME_LINUX_ARM;
} else {
fileName = FILE_NAME_LINUX;
}
} else if (osName.contains(OS_WINDOWS)) {
fileName = FILE_NAME_WINDOWS;
} else {
for (String macStr : OS_MAC) {
if (arch.contains(macStr)) {
if (osName.contains(macStr)) {
fileName = FILE_NAME_MAC;
break;
}
Expand Down

0 comments on commit a04b032

Please sign in to comment.