diff --git a/.gitattributes b/.gitattributes index 6d67ae83..abbedb9b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/.github/scripts/update_cli.sh b/.github/scripts/update_cli.sh index 3a7113f6..50aee4db 100755 --- a/.github/scripts/update_cli.sh +++ b/.github/scripts/update_cli.sh @@ -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 @@ -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} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9acde765..8c0da489 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/update-cli.yml b/.github/workflows/update-cli.yml index 9ec4124f..b3129b50 100644 --- a/.github/workflows/update-cli.yml +++ b/.github/workflows/update-cli.yml @@ -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 diff --git a/src/main/java/com/checkmarx/ast/wrapper/Execution.java b/src/main/java/com/checkmarx/ast/wrapper/Execution.java index 8aec03d5..060563b3 100644 --- a/src/main/java/com/checkmarx/ast/wrapper/Execution.java +++ b/src/main/java/com/checkmarx/ast/wrapper/Execution.java @@ -28,6 +28,7 @@ private Execution() { private static final String OS_WINDOWS = "windows"; private static final List 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"); @@ -143,15 +144,21 @@ private static Process buildProcess(List 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; }