test(nightly): public mobile apps at pinned commits; two scanner fixes they exposed (#482)
This commit was merged in pull request #482.
This commit is contained in:
1 parent
2893a5813e
commit
70e7bc9533
6 files changed
+203
-10
No files matched your search
@@ -131,6 +131,19 @@ jobs:
|
||||
env:
|
||||
RUSTC_WRAPPER: ""
|
||||
|
||||
# Public mobile apps at pinned commits (MIT, Apache-2.0): a current
|
||||
# SwiftUI app and a large Android app, so the mobile checks meet real
|
||||
# projects, not only the hand-written fixtures. Not committed, as with
|
||||
# the Zephyr example.
|
||||
- name: Fetch the public mobile samples
|
||||
run: |
|
||||
curl -fsSL -o /tmp/ios-sample.zip \
|
||||
"https://codeload.github.com/nalexn/clean-architecture-swiftui/zip/9eca97b8cfff96a14084b564b1fefd949c93d232"
|
||||
curl -fsSL -o /tmp/android-sample.zip \
|
||||
"https://codeload.github.com/android/nowinandroid/zip/a49ed253d75e61a2b6ab80a8da677b57437b08eb"
|
||||
env:
|
||||
RUSTC_WRAPPER: ""
|
||||
|
||||
- name: Wait for the agent
|
||||
run: |
|
||||
for i in $(seq 1 90); do
|
||||
@@ -148,6 +161,8 @@ jobs:
|
||||
NIGHTLY_AGENT_URL: http://agent:3001
|
||||
NIGHTLY_CODESYS_SAMPLE: /tmp/csv-blackbox.projectarchive
|
||||
NIGHTLY_ZEPHYR_EXAMPLE: /tmp/zephyr-example.zip
|
||||
NIGHTLY_IOS_SAMPLE: /tmp/ios-sample.zip
|
||||
NIGHTLY_ANDROID_SAMPLE: /tmp/android-sample.zip
|
||||
NIGHTLY_BLESS: ${{ inputs.bless && '1' || '0' }}
|
||||
|
||||
# upload-artifact is a Node action and the Rust image has no node.
|
||||
|
||||
@@ -37,3 +37,17 @@ regex = '''(AIza[\w-]{35})'''
|
||||
path = '''(?i)(?:^|/)(?:google-services\.json|GoogleService-Info\.plist)$'''
|
||||
secretGroup = 1
|
||||
keywords = ["aiza"]
|
||||
|
||||
# Firebase Storage download URLs (`…/o/<file>?alt=media&token=<uuid>`): the
|
||||
# token makes one stored file publicly readable, it is meant to be shipped in
|
||||
# the app with the file's URL, and it grants nothing else. gitleaks' generic
|
||||
# rule reads it as an API key in every app that shows images this way. A line
|
||||
# holding such a URL is not reported; a real key elsewhere on it is rare
|
||||
# enough to accept. (`[allowlist]` rather than `[[allowlists]]`, which the
|
||||
# gitleaks release in the image does not read yet.)
|
||||
[allowlist]
|
||||
description = "Firebase Storage download URLs"
|
||||
regexTarget = "line"
|
||||
regexes = [
|
||||
'''firebasestorage\.googleapis\.com/v0/b/[^/\s"']+/o/[^?\s"']+\?alt=media&(?:amp;)?token=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}''',
|
||||
]
|
||||
@@ -173,18 +173,24 @@ async fn run(
|
||||
}
|
||||
let report = std::fs::read(&report_path).map_err(|e| failed(Box::new(e)))?;
|
||||
let report: Report = serde_json::from_slice(&report)?;
|
||||
// A tool error with nothing found means nothing was checked.
|
||||
if report.results.is_empty() && !report.errors.is_empty() {
|
||||
// A tool error with nothing found means nothing was checked. Semgrep's
|
||||
// warnings (a file it parsed only in part, as with newer Swift syntax)
|
||||
// are not: the rest of the tree was. Neither is logged with its message,
|
||||
// which quotes the scanned code.
|
||||
let (warnings, errors): (Vec<&ReportError>, Vec<&ReportError>) =
|
||||
report.errors.iter().partition(|e| e.is_warning());
|
||||
if report.results.is_empty() && !errors.is_empty() {
|
||||
return Err(failed(
|
||||
format!(
|
||||
"{platform} run reported errors: {}",
|
||||
report.errors.join(" / ")
|
||||
)
|
||||
.into(),
|
||||
format!("{platform} run reported {} error(s)", errors.len()).into(),
|
||||
));
|
||||
}
|
||||
for error in &report.errors {
|
||||
tracing::warn!(%error, platform, "mobsfscan reported an error");
|
||||
if !warnings.is_empty() || !errors.is_empty() {
|
||||
tracing::warn!(
|
||||
platform,
|
||||
warnings = warnings.len(),
|
||||
errors = errors.len(),
|
||||
"mobsfscan could not read every file in full"
|
||||
);
|
||||
}
|
||||
Ok(report.findings(repo_path, repo_id))
|
||||
}
|
||||
@@ -195,7 +201,28 @@ struct Report {
|
||||
#[serde(default)]
|
||||
results: BTreeMap<String, RuleResult>,
|
||||
#[serde(default)]
|
||||
errors: Vec<String>,
|
||||
errors: Vec<ReportError>,
|
||||
}
|
||||
|
||||
/// An entry of the report's `errors`: mobsfscan's own as text, or the
|
||||
/// semgrep error it passes on as an object (`{"level": "warn", …}`).
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
#[serde(untagged)]
|
||||
enum ReportError {
|
||||
Semgrep {
|
||||
#[serde(default)]
|
||||
level: Option<String>,
|
||||
},
|
||||
/// mobsfscan's own, as text; only counted.
|
||||
Text(serde::de::IgnoredAny),
|
||||
}
|
||||
|
||||
impl ReportError {
|
||||
/// Whether it is a warning (a file parsed only in part) rather than a
|
||||
/// failure.
|
||||
fn is_warning(&self) -> bool {
|
||||
matches!(self, Self::Semgrep { level: Some(level) } if level == "warn")
|
||||
}
|
||||
}
|
||||
|
||||
/// One rule's matches and what it says about them.
|
||||
@@ -466,6 +493,22 @@ mod tests {
|
||||
assert_eq!(setting_key(""), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn semgrep_parse_warnings_are_read_and_are_not_failures() {
|
||||
// What mobsfscan writes for a SwiftUI app whose newer syntax semgrep
|
||||
// parses only in part: the error is an object, not a string.
|
||||
let report: Report = serde_json::from_str(
|
||||
r#"{"errors": [
|
||||
{"code": 3, "level": "warn", "message": "Syntax error at line x.swift:1"},
|
||||
{"code": 2, "level": "error", "message": "boom"},
|
||||
"mobsfscan could not read the config"
|
||||
], "results": {}}"#,
|
||||
)
|
||||
.expect("report");
|
||||
let warnings: Vec<bool> = report.errors.iter().map(ReportError::is_warning).collect();
|
||||
assert_eq!(warnings, [true, false, false]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cwe_ids_are_normalised() {
|
||||
assert_eq!(normalise_cwe("cwe-489").as_deref(), Some("CWE-489"));
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"sbom_dependencies"
|
||||
],
|
||||
"sbom": [
|
||||
"github:actions/checkout@v4",
|
||||
"github:actions/create-release@v1",
|
||||
"github:actions/setup-java@v5",
|
||||
"github:actions/upload-artifact@v4",
|
||||
"github:actions/upload-release-asset@v1",
|
||||
"github:android-actions/setup-android@v3",
|
||||
"github:github/codeql-action/upload-sarif@v3",
|
||||
"github:gradle/actions/setup-gradle@v4",
|
||||
"github:jlumbroso/free-disk-space@v1.3.1",
|
||||
"github:madrapps/jacoco-report@v1.7.1",
|
||||
"github:reactivecircus/android-emulator-runner@v2",
|
||||
"github:stefanzweifel/git-auto-commit-action@v5",
|
||||
"maven:accompanist-permissions@0.37.0",
|
||||
"maven:activity-compose@1.9.3",
|
||||
"maven:adaptive-layout@1.1.0-rc01",
|
||||
"maven:adaptive-navigation3@1.3.0-alpha04",
|
||||
"maven:adaptive-navigation@1.1.0-rc01",
|
||||
"maven:adaptive@1.1.0-rc01",
|
||||
"maven:appcompat@1.7.0",
|
||||
"maven:benchmark-macro-junit4@1.5.0-alpha01",
|
||||
"maven:browser@1.8.0",
|
||||
"maven:coil-compose@2.7.0",
|
||||
"maven:coil-svg@2.7.0",
|
||||
"maven:coil@2.7.0",
|
||||
"maven:converter-kotlinx-serialization@2.11.0",
|
||||
"maven:core-ktx@1.15.0",
|
||||
"maven:core-splashscreen@1.0.1",
|
||||
"maven:core@1.7.0-rc01",
|
||||
"maven:datastore@1.2.0",
|
||||
"maven:espresso-core@3.6.1",
|
||||
"maven:foundation@1.8.0-alpha07",
|
||||
"maven:gradle-wrapper@UNKNOWN",
|
||||
"maven:hilt-android-testing@2.59",
|
||||
"maven:hilt-work@1.2.0",
|
||||
"maven:javax.inject@1",
|
||||
"maven:junit-ktx@1.3.0-rc01",
|
||||
"maven:kotlinx-coroutines-core@1.10.1",
|
||||
"maven:kotlinx-coroutines-guava@1.10.1",
|
||||
"maven:kotlinx-coroutines-test@1.10.1",
|
||||
"maven:kotlinx-datetime@0.6.1",
|
||||
"maven:kotlinx-serialization-json@1.8.0",
|
||||
"maven:lifecycle-runtime-compose@2.10.0",
|
||||
"maven:lifecycle-viewmodel-navigation3@2.10.0",
|
||||
"maven:logging-interceptor@4.12.0",
|
||||
"maven:metrics-performance@1.0.0-beta01",
|
||||
"maven:navigation3-runtime@1.0.0",
|
||||
"maven:navigation3-ui@1.0.0",
|
||||
"maven:play-services-oss-licenses@17.1.0",
|
||||
"maven:profileinstaller@1.4.1",
|
||||
"maven:protobuf-kotlin-lite@4.29.2",
|
||||
"maven:retrofit@2.11.0",
|
||||
"maven:robolectric@4.16",
|
||||
"maven:roborazzi-accessibility-check@1.56.0",
|
||||
"maven:roborazzi@1.56.0",
|
||||
"maven:rules@1.7.0-rc01",
|
||||
"maven:runner@1.7.0-rc01",
|
||||
"maven:runtime-tracing@1.7.6",
|
||||
"maven:savedstate-compose@1.3.1",
|
||||
"maven:tracing-ktx@1.3.0-alpha02",
|
||||
"maven:truth@1.4.4",
|
||||
"maven:uiautomator@2.3.0",
|
||||
"maven:window-core@1.3.0",
|
||||
"maven:work-runtime-ktx@2.10.0"
|
||||
],
|
||||
"findings": [
|
||||
"mobsfscan:android_kotlin_logging JankStatsModule.kt:37",
|
||||
"mobsfscan:android_manifest_allow_backup AndroidManifest.xml:20 [app-nia-catalog]",
|
||||
"mobsfscan:android_manifest_allow_backup AndroidManifest.xml:33 [app]",
|
||||
"mobsfscan:android_manifest_missing_explicit_allow_backup AndroidManifest.xml:1",
|
||||
"mobsfscan:android_manifest_missing_explicit_allow_backup AndroidManifest.xml:1 [app]",
|
||||
"mobsfscan:android_task_hijacking2 AndroidManifest.xml:1 [app-nia-catalog]",
|
||||
"mobsfscan:android_task_hijacking2 AndroidManifest.xml:1 [app]"
|
||||
],
|
||||
"cves": []
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"sbom_dependencies"
|
||||
],
|
||||
"sbom": [],
|
||||
"findings": [],
|
||||
"cves": []
|
||||
}
|
||||
@@ -803,6 +803,37 @@
|
||||
],
|
||||
"min_sbom_components": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "mobile-public-ios-swiftui",
|
||||
"name": "iOS · public SwiftUI app (pinned source)",
|
||||
"target_type": "ios_app",
|
||||
"description": "nalexn/clean-architecture-swiftui (MIT) as a source archive at a pinned commit: a current SwiftUI app (iOS 18, Swift 5) whose Xcode project uses Swift packages without a committed Package.resolved. Must be classified as an iOS app, raise no lifecycle or iOS settings findings, and record the unpinned Swift packages under sbom_dependencies. Not committed: the nightly job downloads it into NIGHTLY_IOS_SAMPLE; skipped where that is unset.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload_env": "NIGHTLY_IOS_SAMPLE",
|
||||
"optional": true,
|
||||
"pin": "9eca97b8cfff96a14084b564b1fefd949c93d232"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "mobile-public-android-nowinandroid",
|
||||
"name": "Android · Now in Android (pinned source)",
|
||||
"target_type": "android_app",
|
||||
"description": "android/nowinandroid (Apache-2.0) as a source archive at a pinned commit: a large current Android app with Gradle version catalogs, Compose and many modules. Its direct dependencies must be read from the catalog and build files (no gradle.lockfile, so a recorded sbom_dependencies skip), mobsfscan must run with the Android rules, and its flavors, declared in a convention plugin rather than the app's build file, give no app variants. Not committed: the nightly job downloads it into NIGHTLY_ANDROID_SAMPLE; skipped where that is unset.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload_env": "NIGHTLY_ANDROID_SAMPLE",
|
||||
"optional": true,
|
||||
"pin": "a49ed253d75e61a2b6ab80a8da677b57437b08eb"
|
||||
}
|
||||
],
|
||||
"expect": {
|
||||
"min_sbom_components": 20
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user