narvy-cli 1.3.1__tar.gz → 1.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/CHANGELOG.md +26 -0
- {narvy_cli-1.3.1/narvy_cli.egg-info → narvy_cli-1.3.2}/PKG-INFO +6 -1
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/README.md +5 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/__init__.py +1 -1
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/ci_templates/bitbucket.yml +11 -5
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/ci_templates/github.yml +1 -1
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/ci_templates/gitlab.yml +1 -1
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/main.py +80 -12
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/sca/osv_client.py +76 -10
- narvy_cli-1.3.2/narvy/sca/severity_calibration.py +320 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/sca/web_deps.py +129 -8
- {narvy_cli-1.3.1 → narvy_cli-1.3.2/narvy_cli.egg-info}/PKG-INFO +6 -1
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy_cli.egg-info/SOURCES.txt +1 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/LICENSE +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/MANIFEST.in +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/SECURITY.md +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/__main__.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/android/__init__.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/android/source_analyzer.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/android/split_bundle.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/android_rule_context.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/apk_memory_preflight.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/auth.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/cbom.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/cloud/__init__.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/cloud/aws_scan.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/cloud/gcp_scan.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/cloud/normalize.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/cloud/rule_severity.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/cloud/severity.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/cloud/upload.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/comment_filter.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/crypto_taint_lite.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/decompiler.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/doctor.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/gitlab_report.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/host/__init__.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/host/audit.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/host/host_knowledge.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/host/lynis_bootstrap.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/host/lynis_parser.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/host/narvy_checks.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/host/report.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/host/ssh_exec.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/ios/__init__.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/ios/binary_analyzer.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/ios/plist_checks.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/ios/source_analyzer.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/ios/third_party_filter.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/ios/trust_all_context.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/native_hardening.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/own_reports.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/pathhint.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/pathnorm.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/proc.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/repo_identity.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/reporter.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rule_engine.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/android/config.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/android/crypto.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/android/secrets.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/android/storage.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/android/webview.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/android.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/ios/objc/crypto.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/ios/objc/network.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/ios/objc/secrets.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/ios/objc/storage.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/ios/objc/webview.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/ios_swift.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/web/go.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/web/java.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/web/javascript.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/web/kotlin.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/web/php.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/web/python.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/web/ruby.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/web/rust.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/web/secrets.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/rules/web/secrets_supplement.yml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/sbom.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/sca/__init__.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/sca/android_deps.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/sca/ios_deps.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/sca/osv_localdb.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/sca/osv_semantic.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/scope_config.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/secret_output.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/secret_presentation.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/secret_value_grade.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/semgrep_engine.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/stack_protector_evidence.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/__init__.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/__main__.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/analyze.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/android/__init__.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/android/arsc.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/android/axml.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/android/checks.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/android/elf.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/android/loader.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/android/protoxml.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/android/xmlmodel.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/archive.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/cli.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/data/__init__.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/data/apple.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/data/play.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/ios/__init__.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/ios/checks.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/ios/loader.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/ios/macho.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/store_check/model.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/telemetry.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/third_party_filter.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/uploader.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/weak_prng_context.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/web/__init__.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/web/nuclei_binary.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/web/scan_blocklist.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/web/scanner.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/web/source_analyzer.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy/web/ssrf_guard.py +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy_cli.egg-info/dependency_links.txt +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy_cli.egg-info/entry_points.txt +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy_cli.egg-info/requires.txt +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/narvy_cli.egg-info/top_level.txt +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/pyproject.toml +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/setup.cfg +0 -0
- {narvy_cli-1.3.1 → narvy_cli-1.3.2}/setup.py +0 -0
|
@@ -5,6 +5,32 @@ All notable changes to this project are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.3.2]
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- `scan --upload --fail-on`: findings your team dismissed in Narvy (false
|
|
13
|
+
positive, accepted risk, won't fix) no longer fail the build. The CLI
|
|
14
|
+
reads them from the `dismissed` field of the upload response and prints
|
|
15
|
+
how many it left out. Without `--upload`, or when the server does not
|
|
16
|
+
send that field, the gate uses every local finding as before. A failed
|
|
17
|
+
upload still exits 4 before the gate runs. Reports and the upload itself
|
|
18
|
+
keep every finding.
|
|
19
|
+
- Dependency findings of a source scan get the same severity as on
|
|
20
|
+
narvy.io: the platform's calibration is ported as is
|
|
21
|
+
(`narvy/sca/severity_calibration.py`). A CVE fixed by a release that the
|
|
22
|
+
declared range already admits does not set the severity, and a package
|
|
23
|
+
whose CVEs are all in that case is Low (morgan@1.9.0 with `^1.9.0`: Low,
|
|
24
|
+
was Critical). Also ported: the GitHub-reviewed advisory rating, the
|
|
25
|
+
local or physical attack vector cap (Medium), dev-only dependencies
|
|
26
|
+
(Low) and Go packages whose affected import path is not imported (Low).
|
|
27
|
+
Not ported: the build-only scope (lockfile graph) and the advisory
|
|
28
|
+
preconditions (proxy-addr, ws, nanoid). The advisory's own rating is kept
|
|
29
|
+
in `severity_advisory`, the reasons in `severity_calibration`.
|
|
30
|
+
- `init-ci` templates install `narvy-cli>=1.3.2`. The Bitbucket template
|
|
31
|
+
also runs on pull requests (`pull-requests: '**'`, same step), and
|
|
32
|
+
`init-ci` says when each template runs.
|
|
33
|
+
|
|
8
34
|
## [1.3.1]
|
|
9
35
|
|
|
10
36
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: narvy-cli
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: Local static security scanner for Android and iOS apps and source code, with offline Google Play and App Store upload checks.
|
|
5
5
|
Author: Narvy
|
|
6
6
|
License: Apache-2.0
|
|
@@ -366,6 +366,11 @@ scan starts: a rejected token or an unreachable server exits 4 right away.
|
|
|
366
366
|
| 4 | The scan, login, upload or report write failed |
|
|
367
367
|
| 130 | Interrupted (Ctrl-C, SIGTERM) |
|
|
368
368
|
|
|
369
|
+
With `--upload`, `--fail-on` leaves out the findings your team dismissed in
|
|
370
|
+
Narvy (false positive, accepted risk, won't fix), as listed in the upload
|
|
371
|
+
response, and says how many. Without `--upload`, or when the server does
|
|
372
|
+
not return that list, every local finding counts.
|
|
373
|
+
|
|
369
374
|
`narvy doctor` exits 0 when every required check passes and 1 when one fails.
|
|
370
375
|
Missing optional tools are shown as INFO and do not change its exit code.
|
|
371
376
|
|
|
@@ -327,6 +327,11 @@ scan starts: a rejected token or an unreachable server exits 4 right away.
|
|
|
327
327
|
| 4 | The scan, login, upload or report write failed |
|
|
328
328
|
| 130 | Interrupted (Ctrl-C, SIGTERM) |
|
|
329
329
|
|
|
330
|
+
With `--upload`, `--fail-on` leaves out the findings your team dismissed in
|
|
331
|
+
Narvy (false positive, accepted risk, won't fix), as listed in the upload
|
|
332
|
+
response, and says how many. Without `--upload`, or when the server does
|
|
333
|
+
not return that list, every local finding counts.
|
|
334
|
+
|
|
330
335
|
`narvy doctor` exits 0 when every required check passes and 1 when one fails.
|
|
331
336
|
Missing optional tools are shown as INFO and do not change its exit code.
|
|
332
337
|
|
|
@@ -14,16 +14,22 @@ image: python:3.11
|
|
|
14
14
|
definitions:
|
|
15
15
|
caches:
|
|
16
16
|
narvy-osv: ~/.cache/narvy/osv
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
default:
|
|
20
|
-
- step:
|
|
17
|
+
steps:
|
|
18
|
+
- step: &narvy-sast
|
|
21
19
|
name: Narvy SAST
|
|
22
20
|
caches:
|
|
23
21
|
- narvy-osv
|
|
24
22
|
script:
|
|
25
23
|
- pip install --upgrade pip
|
|
26
|
-
- pip install narvy-cli
|
|
24
|
+
- pip install "narvy-cli>=1.3.2"
|
|
27
25
|
- narvy scan . --output sarif --file narvy-results.sarif --fail-on high ${NARVY_TOKEN:+--upload}
|
|
28
26
|
artifacts:
|
|
29
27
|
- narvy-results.sarif
|
|
28
|
+
|
|
29
|
+
# Every push, and every pull request (same step).
|
|
30
|
+
pipelines:
|
|
31
|
+
default:
|
|
32
|
+
- step: *narvy-sast
|
|
33
|
+
pull-requests:
|
|
34
|
+
'**':
|
|
35
|
+
- step: *narvy-sast
|
|
@@ -25,7 +25,7 @@ jobs:
|
|
|
25
25
|
- name: Install Narvy CLI
|
|
26
26
|
run: |
|
|
27
27
|
python -m pip install --upgrade pip
|
|
28
|
-
pip install narvy-cli
|
|
28
|
+
pip install "narvy-cli>=1.3.2"
|
|
29
29
|
|
|
30
30
|
# The dependency check downloads the OSV database (npm alone is about 220 MB).
|
|
31
31
|
# Kept in the Actions cache, one key per UTC day; the CLI refreshes a copy older than 24 h.
|
|
@@ -30,7 +30,7 @@ narvy_sast:
|
|
|
30
30
|
when: always
|
|
31
31
|
before_script:
|
|
32
32
|
- pip install --upgrade pip
|
|
33
|
-
- pip install "narvy-cli>=1.3.
|
|
33
|
+
- pip install "narvy-cli>=1.3.2"
|
|
34
34
|
script:
|
|
35
35
|
- narvy scan . --output gitlab --file gl-sast-report.json ${NARVY_TOKEN:+--upload} --fail-on high || echo $? > narvy-exit-code
|
|
36
36
|
artifacts:
|
|
@@ -11,7 +11,7 @@ import time
|
|
|
11
11
|
import json
|
|
12
12
|
import zipfile
|
|
13
13
|
from pathlib import Path
|
|
14
|
-
from typing import Any, Dict, List
|
|
14
|
+
from typing import Any, Dict, List, Optional
|
|
15
15
|
from rich.console import Console
|
|
16
16
|
from rich.table import Table
|
|
17
17
|
from rich.progress import Progress
|
|
@@ -1768,9 +1768,42 @@ def _submit_results_ingest(all_findings, scan_mode, target_path, app=None, packa
|
|
|
1768
1768
|
return data
|
|
1769
1769
|
|
|
1770
1770
|
|
|
1771
|
+
# Team triage that keeps a finding out of the build gate (the platform's
|
|
1772
|
+
# "dismissed" statuses: tracker false positive / accepted risk / won't fix).
|
|
1773
|
+
_DISMISSED_STATUSES = frozenset({"false_positive", "accepted_risk", "wont_fix"})
|
|
1774
|
+
|
|
1775
|
+
|
|
1776
|
+
def _dismissed_indices(data, sent_count):
|
|
1777
|
+
"""{index: status} of the submitted findings the team dismissed in Narvy,
|
|
1778
|
+
or None when the response does not say (older server).
|
|
1779
|
+
|
|
1780
|
+
Contract (server side, POST /api/v1/ingest response): ``dismissed`` = a
|
|
1781
|
+
list of {"index": <position in the submitted ``findings`` array>,
|
|
1782
|
+
"status": "false_positive" | "accepted_risk" | "wont_fix"}, present (even
|
|
1783
|
+
empty) whenever the server applied triage. A rolled-up dependency finding
|
|
1784
|
+
lists every submitted index it was built from. Entries out of range or
|
|
1785
|
+
with another status are ignored."""
|
|
1786
|
+
if not isinstance(data, dict) or not isinstance(data.get("dismissed"), list):
|
|
1787
|
+
return None
|
|
1788
|
+
out = {}
|
|
1789
|
+
for e in data["dismissed"]:
|
|
1790
|
+
if not isinstance(e, dict):
|
|
1791
|
+
continue
|
|
1792
|
+
idx, status = e.get("index"), str(e.get("status") or "").strip().lower()
|
|
1793
|
+
if isinstance(idx, int) and not isinstance(idx, bool) and 0 <= idx < sent_count \
|
|
1794
|
+
and status in _DISMISSED_STATUSES:
|
|
1795
|
+
out[idx] = status
|
|
1796
|
+
return out
|
|
1797
|
+
|
|
1798
|
+
|
|
1771
1799
|
def _submit_results_by_surface(all_findings, scan_mode, target_path, scan_meta=None, app=None):
|
|
1772
|
-
"""Upload each scanned surface under its own platform (nested iOS goes up as iOS source).
|
|
1800
|
+
"""Upload each scanned surface under its own platform (nested iOS goes up as iOS source).
|
|
1801
|
+
|
|
1802
|
+
Returns the findings of ``all_findings`` the team dismissed in Narvy (a
|
|
1803
|
+
list, possibly empty) when EVERY upload's response carried the
|
|
1804
|
+
``dismissed`` field, else None (the build gate then stays local)."""
|
|
1773
1805
|
by_root: Dict[str, List[Dict[str, Any]]] = {}
|
|
1806
|
+
origin: Dict[str, List[Dict[str, Any]]] = {}
|
|
1774
1807
|
main: List[Dict[str, Any]] = []
|
|
1775
1808
|
for f in all_findings:
|
|
1776
1809
|
root = f.get("_surface_root")
|
|
@@ -1781,18 +1814,32 @@ def _submit_results_by_surface(all_findings, scan_mode, target_path, scan_meta=N
|
|
|
1781
1814
|
if fp.startswith(prefix):
|
|
1782
1815
|
g["file_path"] = fp[len(prefix):]
|
|
1783
1816
|
by_root.setdefault(root, []).append(g)
|
|
1817
|
+
origin.setdefault(root, []).append(f)
|
|
1784
1818
|
else:
|
|
1785
1819
|
main.append(f)
|
|
1786
1820
|
for s in (scan_meta or {}).get("surfaces", [])[1:]:
|
|
1787
1821
|
if s.get("mode") == "ios-source" and s.get("status") != "failed":
|
|
1788
1822
|
by_root.setdefault(s["path"], [])
|
|
1823
|
+
origin.setdefault(s["path"], [])
|
|
1824
|
+
dismissed: Optional[List[Dict[str, Any]]] = []
|
|
1789
1825
|
# --app targets the scanned project; a nested iOS project keeps its own app.
|
|
1790
|
-
_submit_results_ingest(main, scan_mode, target_path, app=app,
|
|
1791
|
-
|
|
1792
|
-
|
|
1826
|
+
data = _submit_results_ingest(main, scan_mode, target_path, app=app,
|
|
1827
|
+
package_id=(scan_meta or {}).get("package_id"),
|
|
1828
|
+
sca_coverage=_sca_coverage_word(scan_meta))
|
|
1829
|
+
idx = _dismissed_indices(data, len(main))
|
|
1830
|
+
if idx is None:
|
|
1831
|
+
dismissed = None
|
|
1832
|
+
else:
|
|
1833
|
+
dismissed.extend(main[i] for i in sorted(idx))
|
|
1793
1834
|
for root, findings in by_root.items():
|
|
1794
1835
|
console.print(f"[dim]iOS project in {rich_escape(root)}/:[/dim]")
|
|
1795
|
-
_submit_results_ingest(findings, "ios-source", os.path.join(target_path, root))
|
|
1836
|
+
data = _submit_results_ingest(findings, "ios-source", os.path.join(target_path, root))
|
|
1837
|
+
idx = _dismissed_indices(data, len(findings))
|
|
1838
|
+
if idx is None:
|
|
1839
|
+
dismissed = None
|
|
1840
|
+
elif dismissed is not None:
|
|
1841
|
+
dismissed.extend(origin[root][i] for i in sorted(idx))
|
|
1842
|
+
return dismissed
|
|
1796
1843
|
|
|
1797
1844
|
|
|
1798
1845
|
_ENGINE_LABELS = {
|
|
@@ -2434,9 +2481,10 @@ def cmd_scan(args):
|
|
|
2434
2481
|
if _premium_note:
|
|
2435
2482
|
console.print(f"\n[dim]{rich_escape(_premium_note)}[/dim]")
|
|
2436
2483
|
|
|
2484
|
+
team_dismissed = None
|
|
2437
2485
|
if args.upload and not getattr(args, "upload_binary", False):
|
|
2438
|
-
_submit_results_by_surface(all_findings, scan_mode, target_path, scan_meta,
|
|
2439
|
-
|
|
2486
|
+
team_dismissed = _submit_results_by_surface(all_findings, scan_mode, target_path, scan_meta,
|
|
2487
|
+
app=getattr(args, "app", None))
|
|
2440
2488
|
elif args.upload:
|
|
2441
2489
|
# Legacy --upload-binary: POST the binary and let the server re-scan it.
|
|
2442
2490
|
# upload_scan() opens the path in binary mode, so refuse a directory.
|
|
@@ -2636,8 +2684,23 @@ def cmd_scan(args):
|
|
|
2636
2684
|
_gap_note = semgrep_engine.degraded_coverage_note()
|
|
2637
2685
|
if _gap_note:
|
|
2638
2686
|
coverage_gaps.append(_gap_note)
|
|
2639
|
-
_exit_on_fail_on(all_findings, getattr(args, "fail_on", None),
|
|
2640
|
-
coverage_gaps=coverage_gaps)
|
|
2687
|
+
_exit_on_fail_on(_gate_findings(all_findings, team_dismissed, getattr(args, "fail_on", None)),
|
|
2688
|
+
getattr(args, "fail_on", None), coverage_gaps=coverage_gaps)
|
|
2689
|
+
|
|
2690
|
+
|
|
2691
|
+
def _gate_findings(all_findings, team_dismissed, fail_on):
|
|
2692
|
+
"""The findings --fail-on gates on: all of them, minus the ones the team
|
|
2693
|
+
dismissed in Narvy when the upload's response said which (else the local
|
|
2694
|
+
gate, unchanged). Reports, SARIF and the upload keep every finding."""
|
|
2695
|
+
if not team_dismissed:
|
|
2696
|
+
return all_findings
|
|
2697
|
+
gone = {id(f) for f in team_dismissed}
|
|
2698
|
+
kept = [f for f in all_findings if id(f) not in gone]
|
|
2699
|
+
excluded = len(all_findings) - len(kept)
|
|
2700
|
+
if fail_on and excluded:
|
|
2701
|
+
console.print(f"[dim]--fail-on: {excluded} finding(s) excluded because your team "
|
|
2702
|
+
"dismissed them in Narvy (false positive, accepted risk or won't fix).[/dim]")
|
|
2703
|
+
return kept
|
|
2641
2704
|
|
|
2642
2705
|
|
|
2643
2706
|
_UPLOAD_ALL_TARGET_EXTS = (".apk", ".aab", ".apkm", ".xapk", ".ipa")
|
|
@@ -3436,9 +3499,14 @@ def cmd_init_ci(args):
|
|
|
3436
3499
|
raise SystemExit(EXIT_ERROR)
|
|
3437
3500
|
|
|
3438
3501
|
console.print(f"[bold green]Wrote {platform} CI template to {dest}[/bold green]")
|
|
3502
|
+
_runs_on = {
|
|
3503
|
+
"github": "on pushes to main or master and on every pull request",
|
|
3504
|
+
"gitlab": "on every push (merge request branches included)",
|
|
3505
|
+
"bitbucket": "on every push and every pull request",
|
|
3506
|
+
}.get(platform, "on every push")
|
|
3439
3507
|
console.print(
|
|
3440
|
-
"[dim]It installs the CLI from PyPI with [bold]pip install narvy-cli[/bold] "
|
|
3441
|
-
"and runs
|
|
3508
|
+
"[dim]It installs the CLI from PyPI with [bold]pip install \"narvy-cli>=1.3.2\"[/bold] "
|
|
3509
|
+
f"and runs {_runs_on}.[/dim]"
|
|
3442
3510
|
)
|
|
3443
3511
|
if platform == "gitlab":
|
|
3444
3512
|
console.print(
|
|
@@ -209,6 +209,12 @@ class OSVFinding:
|
|
|
209
209
|
package_name: str = ""
|
|
210
210
|
package_version: str = ""
|
|
211
211
|
ecosystem: str = ""
|
|
212
|
+
# SCA severity calibration inputs, read like the platform's osv_client:
|
|
213
|
+
# the GitHub-reviewed label (GHSA records only), the CVSS v3 vector (v4
|
|
214
|
+
# when no v3) and the Go import paths the advisory lists.
|
|
215
|
+
reviewed_severity: str = ""
|
|
216
|
+
cvss_vector: str = ""
|
|
217
|
+
affected_imports: List[str] = field(default_factory=list)
|
|
212
218
|
|
|
213
219
|
def to_dict(self) -> Dict[str, Any]:
|
|
214
220
|
return {
|
|
@@ -218,6 +224,9 @@ class OSVFinding:
|
|
|
218
224
|
"cve_id": self.cve,
|
|
219
225
|
"osv_id": self.osv_id,
|
|
220
226
|
"cwe": self.cwe,
|
|
227
|
+
"reviewed_severity": self.reviewed_severity,
|
|
228
|
+
"cvss_vector": self.cvss_vector,
|
|
229
|
+
"affected_imports": list(self.affected_imports),
|
|
221
230
|
"severity": self.severity,
|
|
222
231
|
"cvss_score": self.cvss_score,
|
|
223
232
|
"summary": self.summary,
|
|
@@ -559,6 +568,27 @@ def _parse_osv_vuln(
|
|
|
559
568
|
|
|
560
569
|
fixed_version: Optional[str] = _pick_fixed_version(raw, package_name, package_version)
|
|
561
570
|
|
|
571
|
+
# ---- Calibration inputs (same reading as the platform's osv_client) ----
|
|
572
|
+
reviewed_severity = ""
|
|
573
|
+
if str(osv_id).startswith("GHSA-"):
|
|
574
|
+
_lbl = str((raw.get("database_specific") or {}).get("severity") or "").upper()
|
|
575
|
+
if _lbl in ("CRITICAL", "HIGH", "MODERATE", "MEDIUM", "LOW"):
|
|
576
|
+
reviewed_severity = "MEDIUM" if _lbl == "MODERATE" else _lbl
|
|
577
|
+
cvss_vector = ""
|
|
578
|
+
for _entry in sev_arr:
|
|
579
|
+
_vec = str((_entry or {}).get("score") or "") if isinstance(_entry, dict) else ""
|
|
580
|
+
if _vec.startswith("CVSS:3"):
|
|
581
|
+
cvss_vector = _vec
|
|
582
|
+
break
|
|
583
|
+
if _vec.startswith("CVSS:4") and not cvss_vector:
|
|
584
|
+
cvss_vector = _vec
|
|
585
|
+
affected_imports: List[str] = []
|
|
586
|
+
for _aff in raw.get("affected", []) or []:
|
|
587
|
+
for _imp in (((_aff or {}).get("ecosystem_specific") or {}).get("imports") or []):
|
|
588
|
+
_path = _imp.get("path") if isinstance(_imp, dict) else None
|
|
589
|
+
if _path and _path not in affected_imports:
|
|
590
|
+
affected_imports.append(str(_path))
|
|
591
|
+
|
|
562
592
|
refs = []
|
|
563
593
|
for ref in raw.get("references", []) or []:
|
|
564
594
|
url = ref.get("url")
|
|
@@ -590,6 +620,9 @@ def _parse_osv_vuln(
|
|
|
590
620
|
package_name=package_name,
|
|
591
621
|
package_version=package_version,
|
|
592
622
|
ecosystem=ecosystem,
|
|
623
|
+
reviewed_severity=reviewed_severity,
|
|
624
|
+
cvss_vector=cvss_vector,
|
|
625
|
+
affected_imports=affected_imports,
|
|
593
626
|
)
|
|
594
627
|
|
|
595
628
|
|
|
@@ -844,16 +877,49 @@ class OSVClient:
|
|
|
844
877
|
self.cache.put(package_name, version, ecosystem, raw_vulns)
|
|
845
878
|
return self._parse_all(raw_vulns, package_name, version, ecosystem)
|
|
846
879
|
|
|
847
|
-
def query_dict(self, package_name: str, version: str, ecosystem: str = "Maven"
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
880
|
+
def query_dict(self, package_name: str, version: str, ecosystem: str = "Maven",
|
|
881
|
+
platform_grouping: bool = False) -> List[Dict[str, Any]]:
|
|
882
|
+
"""One dict per CVE (OSV lists one CVE under several advisory ids:
|
|
883
|
+
GHSA / PYSEC / CVE).
|
|
884
|
+
|
|
885
|
+
Default: the first record of each CVE. ``platform_grouping``: the
|
|
886
|
+
record the platform keeps (web_sca._finding_from_osv_group): the
|
|
887
|
+
GitHub-reviewed one when there is one, else the highest CVSS; each
|
|
888
|
+
dict then also carries ``mirror_worst_severity``, the worst rating
|
|
889
|
+
across that CVE's records, and ``advisory_worst_severity``, the worst
|
|
890
|
+
across every record of the package (the calibration's ceiling)."""
|
|
891
|
+
found = list(self.query(package_name, version, ecosystem))
|
|
892
|
+
if not platform_grouping:
|
|
893
|
+
out: List[Dict[str, Any]] = []
|
|
894
|
+
seen = set()
|
|
895
|
+
for f in found:
|
|
896
|
+
key = getattr(f, "cve", "") or getattr(f, "osv_id", "") or id(f)
|
|
897
|
+
if key in seen:
|
|
898
|
+
continue
|
|
899
|
+
seen.add(key)
|
|
900
|
+
out.append(f.to_dict())
|
|
901
|
+
return out
|
|
902
|
+
from . import severity_calibration as _cal
|
|
903
|
+
advisory_worst = _cal.worst(_cal.canonical(f.severity) for f in found)
|
|
904
|
+
by_key: Dict[Any, OSVFinding] = {}
|
|
905
|
+
group_worst: Dict[Any, str] = {}
|
|
906
|
+
for f in found:
|
|
907
|
+
key = f.cve if (f.cve and f.cve.startswith("CVE-")) else f.osv_id
|
|
908
|
+
group_worst[key] = _cal.worst([group_worst.get(key, "Info"), _cal.canonical(f.severity)])
|
|
909
|
+
existing = by_key.get(key)
|
|
910
|
+
if existing is None:
|
|
911
|
+
by_key[key] = f
|
|
912
|
+
elif bool(f.reviewed_severity) != bool(existing.reviewed_severity):
|
|
913
|
+
if f.reviewed_severity:
|
|
914
|
+
by_key[key] = f
|
|
915
|
+
elif f.cvss_score > existing.cvss_score:
|
|
916
|
+
by_key[key] = f
|
|
917
|
+
out = []
|
|
918
|
+
for key, f in by_key.items():
|
|
919
|
+
d = f.to_dict()
|
|
920
|
+
d["mirror_worst_severity"] = group_worst[key]
|
|
921
|
+
d["advisory_worst_severity"] = advisory_worst
|
|
922
|
+
out.append(d)
|
|
857
923
|
return out
|
|
858
924
|
|
|
859
925
|
@staticmethod
|