From 3458e235903c5a6c0dbd82ffa0cfc6dcc78c3a1c Mon Sep 17 00:00:00 2001 From: 0xh3rman <119309671+0xh3rman@users.noreply.github.com> Date: Sat, 8 Nov 2025 08:04:35 +0900 Subject: [PATCH 1/3] Add MobSF static analysis integration and config Introduces MobSF mobsfscan for static security analysis with a new GitHub Actions workflow, a .mobsf configuration file, and a justfile command for local usage. Updates the README with security scanning instructions and adds inline suppressions for specific MobSF rules. Also includes minor code cleanups and enum case renaming for consistency. --- .github/workflows/mobsfscan.yml | 48 +++++++++++++++++++ .mobsf | 24 ++++++++++ .../FiatTransactionTypeViewModel.swift | 2 +- .../Sources/Types/WalletImportType.swift | 6 +-- .../Sources/LocalKeystorePassword.swift | 2 +- Packages/Style/Sources/Emoji.swift | 2 +- README.md | 9 ++++ justfile | 8 +++- 8 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/mobsfscan.yml create mode 100644 .mobsf diff --git a/.github/workflows/mobsfscan.yml b/.github/workflows/mobsfscan.yml new file mode 100644 index 000000000..de246eb0d --- /dev/null +++ b/.github/workflows/mobsfscan.yml @@ -0,0 +1,48 @@ +name: MobSF Scan + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +permissions: + contents: read + security-events: write + +jobs: + mobsfscan: + name: mobsfscan static analysis + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + + - name: Install mobsfscan + run: uv tool install mobsfscan + + - name: Run mobsfscan + run: | + set +e + uv tool run mobsfscan -- --type ios --config .mobsf --sarif --output results.sarif --exit-warning + EXIT_CODE=$? + echo "MOBSF_EXIT=${EXIT_CODE}" >> "$GITHUB_ENV" + exit 0 + + - name: Upload mobsfscan SARIF + if: always() && hashFiles('results.sarif') != '' + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: results.sarif + + - name: Fail when mobsfscan finds issues + if: ${{ env.MOBSF_EXIT != '' && env.MOBSF_EXIT != '0' }} + run: | + echo "mobsfscan reported security findings. Review the SARIF upload for details." + exit 1 diff --git a/.mobsf b/.mobsf new file mode 100644 index 000000000..abd9209f2 --- /dev/null +++ b/.mobsf @@ -0,0 +1,24 @@ +--- +- ignore-paths: + - build + - .build + - blockchains + - core + - Gem.xcodeproj + - Gem/Generated + - GemTests/Fixtures + - GemTests + - github.com + - Packages/Keystore/Tests + - Packages/Keychain/Tests + - Packages/Keychain/Sources/Types/Accessibility.swift + - Packages/Keystore/TestKit + - Packages/Gemstone + - Packages/GemstonePrimitives + - Packages/Primitives/Sources/Extensions/Color+Primitives.swift + - Packages/Primitives/Sources/TransactionLoadMetadata.swift + - scripts + - swiftgen.yml + severity-filter: + - WARNING + - ERROR diff --git a/Features/FiatConnect/Sources/ViewModels/FiatTransactionTypeViewModel.swift b/Features/FiatConnect/Sources/ViewModels/FiatTransactionTypeViewModel.swift index ac8ac2c26..7122d17c6 100644 --- a/Features/FiatConnect/Sources/ViewModels/FiatTransactionTypeViewModel.swift +++ b/Features/FiatConnect/Sources/ViewModels/FiatTransactionTypeViewModel.swift @@ -31,7 +31,7 @@ public extension FiatQuoteTypeViewModel { func randomAmount(maxAmount: Double) -> Double? { switch type { - case .buy: Double(Int.random(in: Int(defaultAmount)../dev/null || { \ + echo "uv is not installed. Install it via 'curl -LsSf https://astral.sh/uv/install.sh | sh'."; \ + exit 1; } + uv tool run mobsfscan -- --type ios --config .mobsf --exit-warning + localize: @sh core/scripts/localize.sh ios Packages/Localization/Sources/Resources just generate-model @@ -138,4 +144,4 @@ generate-stone: bump-version: @sh ./scripts/bump-version-and-commit.sh patch -mod core \ No newline at end of file +mod core From 8d2df19bb253eb2ddda5bdf6d732e58543c4d8a6 Mon Sep 17 00:00:00 2001 From: 0xh3rman <119309671+0xh3rman@users.noreply.github.com> Date: Sat, 8 Nov 2025 08:16:55 +0900 Subject: [PATCH 2/3] Update .mobsf --- .mobsf | 2 -- 1 file changed, 2 deletions(-) diff --git a/.mobsf b/.mobsf index abd9209f2..7fb125352 100644 --- a/.mobsf +++ b/.mobsf @@ -2,13 +2,11 @@ - ignore-paths: - build - .build - - blockchains - core - Gem.xcodeproj - Gem/Generated - GemTests/Fixtures - GemTests - - github.com - Packages/Keystore/Tests - Packages/Keychain/Tests - Packages/Keychain/Sources/Types/Accessibility.swift From 63b8c7305d70e5a2ba8f339a98528c1bf8ec580b Mon Sep 17 00:00:00 2001 From: 0xh3rman <119309671+0xh3rman@users.noreply.github.com> Date: Sat, 8 Nov 2025 08:26:58 +0900 Subject: [PATCH 3/3] Update .mobsf --- .mobsf | 1 - 1 file changed, 1 deletion(-) diff --git a/.mobsf b/.mobsf index 7fb125352..c259cc41e 100644 --- a/.mobsf +++ b/.mobsf @@ -15,7 +15,6 @@ - Packages/GemstonePrimitives - Packages/Primitives/Sources/Extensions/Color+Primitives.swift - Packages/Primitives/Sources/TransactionLoadMetadata.swift - - scripts - swiftgen.yml severity-filter: - WARNING