feat(ios): Carthage pins in the SBOM, iOS and Swift lifecycle findings
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 10m8s
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 10m8s
iOS readiness, story 1 (detection and SBOM). Syft already reads
Podfile.lock and Package.resolved (also inside the Xcode project); what
was missing:
- Carthage: Cartfile.resolved is read (sbom/carthage.rs). A github/git
pin is the same repository at the same tag as its Swift package, so it
gets the purl OSV keys Swift advisories by
(pkg:swift/github.com/grpc/grpc-swift@1.0.0) and is matched; a
repository also pinned through SwiftPM is listed once. A binary
framework is listed without a purl, and the coverage note names its
Cartfile.resolved, since no advisory database covers it. A Cartfile
without Cartfile.resolved is now the gap (was: every Cartfile).
- build-lifecycle reads every app project.pbxproj (not Pods or Carthage
checkouts) at its lowest setting:
- ios-deployment-target-end-of-support (Low): IPHONEOS_DEPLOYMENT_TARGET
below 15 lets the app install on iOS releases without security updates
(iOS 15 got 15.8.8 in May 2026; 14 and 12 are end of life).
- swift-version-end-of-support (Medium): SWIFT_VERSION below 4, which no
Xcode since 10.2 builds.
Both map to cra-ai-22; the binding now covers swift/objc. The Xcode
version is not judged: a repository does not record it.
- Classification: an .xcworkspace or a Cartfile also marks an iOS app.
- Nightly fixture mobile/ios-carthage-legacy (Swift 3, iOS 10, Carthage
with Alamofire, grpc-swift and a binary framework): baseline holds the
four grpc-swift advisories and both lifecycle findings.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
1 parent
34688fa322
commit
56fa334b75
14 files changed
+547
-19
No files matched your search
@@ -377,14 +377,16 @@ impl HeuristicClassifier {
|
||||
out.push(verdict(target_type, confidence, why, facts));
|
||||
}
|
||||
if m.any_dir_ends_with(".xcodeproj")
|
||||
|| m.any_dir_ends_with(".xcworkspace")
|
||||
|| m.has_file("info.plist")
|
||||
|| m.has_file("cartfile")
|
||||
|| m.has_file("podfile")
|
||||
|| m.has_ext("ipa")
|
||||
{
|
||||
out.push(verdict(
|
||||
TargetType::IosApp,
|
||||
0.8,
|
||||
"Xcode project / Info.plist",
|
||||
"Xcode project / Info.plist / CocoaPods / Carthage",
|
||||
facts_lang("swift/objc"),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
//! no complete SBOM and no CVE monitoring are possible. That is the finding,
|
||||
//! and modernising the build is the remedy. The platform such a project builds
|
||||
//! for is a finding of its own when it no longer gets security updates (an
|
||||
//! old Android API level, an old Unity editor).
|
||||
//! old Android API level, an old Unity editor, an iOS deployment target that
|
||||
//! admits unpatched iOS releases), and so is a Swift language version no
|
||||
//! supported Xcode builds.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
@@ -24,6 +26,16 @@ pub const SCANNER: &str = "build-lifecycle";
|
||||
/// security updates any more.
|
||||
const OLDEST_PATCHED_ANDROID_API: u32 = 29;
|
||||
|
||||
/// The oldest iOS release that still receives security updates: iOS 15 got
|
||||
/// 15.8.8 in May 2026, while iOS 14 was last updated in October 2021 and the
|
||||
/// older iOS 12 line in January 2026, both now end of life (endoflife.date).
|
||||
/// Judged conservatively like Unity: below it is certainly unpatched.
|
||||
const OLDEST_PATCHED_IOS: (u32, u32) = (15, 0);
|
||||
|
||||
/// The oldest Swift language version a supported Xcode builds: Xcode 10.2
|
||||
/// dropped Swift 3 mode, and current Swift compilers accept 4, 4.2, 5 and 6.
|
||||
const OLDEST_BUILDABLE_SWIFT: (u32, u32) = (4, 0);
|
||||
|
||||
/// How deep projects are looked for.
|
||||
const MAX_DEPTH: usize = 8;
|
||||
|
||||
@@ -38,6 +50,8 @@ const SKIPPED_DIRS: &[&str] = &[
|
||||
"Library",
|
||||
"Temp",
|
||||
"Pods",
|
||||
"Carthage",
|
||||
"DerivedData",
|
||||
];
|
||||
|
||||
/// The checks over a tree.
|
||||
@@ -97,6 +111,13 @@ pub(crate) fn check_tree(root: &Path) -> Vec<Hit> {
|
||||
hits.extend(check_unity_project(root, project));
|
||||
}
|
||||
}
|
||||
"project.pbxproj"
|
||||
if dir.file_name().is_some_and(|n| {
|
||||
n != "Pods.xcodeproj" && n.to_string_lossy().ends_with(".xcodeproj")
|
||||
}) =>
|
||||
{
|
||||
hits.extend(check_xcode_project(root, entry.path()));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -188,6 +209,92 @@ fn android_api(line: &str) -> Option<u32> {
|
||||
.and_then(|n| n.trim().parse().ok())
|
||||
}
|
||||
|
||||
/// The lowest value of a build setting in an Xcode project file
|
||||
/// (`IPHONEOS_DEPLOYMENT_TARGET = 12.0;`), as (major, minor), with its
|
||||
/// 1-based line. Every build configuration of every target sets it, and the
|
||||
/// lowest is what ships.
|
||||
fn lowest_setting(text: &str, setting: &str) -> Option<((u32, u32), u32)> {
|
||||
text.lines()
|
||||
.enumerate()
|
||||
.filter_map(|(i, line)| {
|
||||
let value = line.trim().strip_prefix(setting)?.trim_start();
|
||||
let value = value.strip_prefix('=')?.trim().trim_end_matches(';');
|
||||
let line_number = u32::try_from(i + 1).ok()?;
|
||||
Some((version_pair(value.trim_matches('"'))?, line_number))
|
||||
})
|
||||
.min_by_key(|(version, _)| *version)
|
||||
}
|
||||
|
||||
/// `12`, `12.0` or `4.2` as (major, minor).
|
||||
fn version_pair(value: &str) -> Option<(u32, u32)> {
|
||||
let mut parts = value.split('.');
|
||||
let major = parts.next()?.parse().ok()?;
|
||||
let minor = parts.next().map_or(Some(0), |m| m.parse().ok())?;
|
||||
Some((major, minor))
|
||||
}
|
||||
|
||||
/// An Xcode project file at `file`: its lowest iOS deployment target and
|
||||
/// Swift language version.
|
||||
fn check_xcode_project(root: &Path, file: &Path) -> Vec<Hit> {
|
||||
let Ok(text) = std::fs::read_to_string(file) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let project = file
|
||||
.parent()
|
||||
.map_or_else(String::new, |p| relative(root, p));
|
||||
let path = relative(root, file);
|
||||
let mut hits = Vec::new();
|
||||
if let Some(((major, minor), line)) = lowest_setting(&text, "IPHONEOS_DEPLOYMENT_TARGET") {
|
||||
if (major, minor) < OLDEST_PATCHED_IOS {
|
||||
let (oldest, _) = OLDEST_PATCHED_IOS;
|
||||
hits.push(Hit {
|
||||
scanner: SCANNER,
|
||||
scan_type: ScanType::Sbom,
|
||||
rule_id: "ios-deployment-target-end-of-support",
|
||||
title: format!(
|
||||
"The app installs on iOS {major}.{minor}, which receives no security updates"
|
||||
),
|
||||
description: format!(
|
||||
"{project} sets its iOS deployment target to {major}.{minor}: the app \
|
||||
installs and runs on devices still on that release. iOS releases below \
|
||||
{oldest} receive no security updates, so those devices stay vulnerable \
|
||||
whatever the app does. The app also runs on current iOS releases."
|
||||
),
|
||||
remediation: "Raise IPHONEOS_DEPLOYMENT_TARGET of every target and build \
|
||||
configuration to a supported iOS release, and test on it.",
|
||||
severity: Severity::Low,
|
||||
cwe: "CWE-1104",
|
||||
path: path.clone(),
|
||||
line: Some(line),
|
||||
});
|
||||
}
|
||||
}
|
||||
if let Some(((major, minor), line)) = lowest_setting(&text, "SWIFT_VERSION") {
|
||||
if (major, minor) < OLDEST_BUILDABLE_SWIFT {
|
||||
hits.push(Hit {
|
||||
scanner: SCANNER,
|
||||
scan_type: ScanType::Sbom,
|
||||
rule_id: "swift-version-end-of-support",
|
||||
title: format!("Swift {major}.{minor} cannot be built with a supported Xcode"),
|
||||
description: format!(
|
||||
"{project} is written for Swift {major}.{minor}. No Xcode release since \
|
||||
10.2 (2019) builds Swift 3 or older, so the app can only be built with \
|
||||
tools that receive no updates, and a security fix cannot be shipped \
|
||||
without migrating it first."
|
||||
),
|
||||
remediation: "Migrate the code to Swift 5 or later (Xcode migrates Swift 4 \
|
||||
code; older code through an Xcode release that still reads it) \
|
||||
and set SWIFT_VERSION accordingly.",
|
||||
severity: Severity::Medium,
|
||||
cwe: "CWE-1104",
|
||||
path,
|
||||
line: Some(line),
|
||||
});
|
||||
}
|
||||
}
|
||||
hits
|
||||
}
|
||||
|
||||
/// A Unity project at `project`: without `Packages/manifest.json` its packages
|
||||
/// are not declared; an editor version out of support is a finding of its own.
|
||||
fn check_unity_project(root: &Path, project: &Path) -> Vec<Hit> {
|
||||
@@ -347,6 +454,50 @@ mod tests {
|
||||
assert!(hits(&t).is_empty(), "{:?}", hits(&t));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn old_xcode_settings_give_lifecycle_findings_at_their_lowest_value() {
|
||||
let pbxproj = "\
|
||||
// !$*UTF8*$!
|
||||
\t\t\tbuildSettings = {
|
||||
\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
\t\t\t\tSWIFT_VERSION = 4.2;
|
||||
\t\t\t};
|
||||
\t\t\tbuildSettings = {
|
||||
\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 9.3;
|
||||
\t\t\t\tSWIFT_VERSION = 3.0;
|
||||
\t\t\t};
|
||||
";
|
||||
let t = tree(&[
|
||||
("PumpApp/PumpApp.xcodeproj/project.pbxproj", pbxproj),
|
||||
// Dependencies' projects are theirs, not the app's.
|
||||
("PumpApp/Pods/Pods.xcodeproj/project.pbxproj", pbxproj),
|
||||
(
|
||||
"Carthage/Checkouts/Lib/Lib.xcodeproj/project.pbxproj",
|
||||
pbxproj,
|
||||
),
|
||||
]);
|
||||
assert_eq!(
|
||||
hits(&t),
|
||||
[
|
||||
"ios-deployment-target-end-of-support \
|
||||
PumpApp/PumpApp.xcodeproj/project.pbxproj:7",
|
||||
"swift-version-end-of-support PumpApp/PumpApp.xcodeproj/project.pbxproj:8",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn current_xcode_settings_give_nothing() {
|
||||
let t = tree(&[(
|
||||
"App.xcodeproj/project.pbxproj",
|
||||
"IPHONEOS_DEPLOYMENT_TARGET = 15.0;\nSWIFT_VERSION = 5.0;\n\
|
||||
IPHONEOS_DEPLOYMENT_TARGET = \"16\";\nSWIFT_VERSION = 4.0;\n",
|
||||
)]);
|
||||
assert!(hits(&t).is_empty(), "{:?}", hits(&t));
|
||||
assert_eq!(version_pair("16"), Some((16, 0)));
|
||||
assert_eq!(version_pair("$(inherited)"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unity_support_is_judged_conservatively() {
|
||||
assert!(unity_out_of_support("2019.2.4f1"));
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
//! Components an iOS app pins with Carthage.
|
||||
//!
|
||||
//! `Cartfile.resolved` pins every dependency, one per line:
|
||||
//! `github "Alamofire/Alamofire" "5.4.0"`, `git "https://host/x/y.git" "v1.2"`
|
||||
//! or `binary "https://vendor/Sdk.json" "3.1.0"`. No SBOM tool reads it, so it
|
||||
//! is read here.
|
||||
//!
|
||||
//! A `github` or `git` pin is a Swift (or Objective-C) repository at a tag, the
|
||||
//! same repository and tags a Swift package of it would use. It is therefore
|
||||
//! given the purl OSV keys Swift advisories by,
|
||||
//! `pkg:swift/github.com/Alamofire/Alamofire@5.4.0`, and is matched like one.
|
||||
//! A `binary` pin is a prebuilt vendor framework: it is listed without a purl,
|
||||
//! as no advisory database covers it (see
|
||||
//! [`super::mobile::unlocked_mobile_ecosystems`], which says so).
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use compliance_core::models::SbomEntry;
|
||||
|
||||
use super::mobile::{MAX_DEPTH, SKIPPED_DIRS};
|
||||
|
||||
/// The package manager name of every Carthage component.
|
||||
pub(crate) const CARTHAGE_MANAGER: &str = "carthage";
|
||||
|
||||
/// The file that pins Carthage dependencies.
|
||||
pub(crate) const RESOLVED_FILE: &str = "Cartfile.resolved";
|
||||
|
||||
/// One line of `Cartfile.resolved`.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub(crate) struct Pin {
|
||||
/// The repository (`Alamofire/Alamofire`, `https://host/x/y.git`) or the
|
||||
/// binary spec URL.
|
||||
pub source: String,
|
||||
/// The tag, version or commit it is pinned at.
|
||||
pub version: String,
|
||||
/// Whether it is a prebuilt `binary` framework.
|
||||
pub binary: bool,
|
||||
}
|
||||
|
||||
/// The pins of one `Cartfile.resolved`; lines that are not pins (comments,
|
||||
/// blank lines, unknown kinds) are skipped.
|
||||
pub(crate) fn parse_resolved(text: &str) -> Vec<Pin> {
|
||||
text.lines()
|
||||
.filter_map(|line| {
|
||||
let (kind, rest) = line.trim().split_once(char::is_whitespace)?;
|
||||
let binary = match kind {
|
||||
"github" | "git" => false,
|
||||
"binary" => true,
|
||||
_ => return None,
|
||||
};
|
||||
// The rest is two quoted strings: `"source" "version"`.
|
||||
let mut quoted = rest.split('"').skip(1).step_by(2);
|
||||
Some(Pin {
|
||||
source: quoted.next()?.to_string(),
|
||||
version: quoted.next()?.to_string(),
|
||||
binary,
|
||||
})
|
||||
})
|
||||
.filter(|pin| !pin.source.is_empty() && !pin.version.is_empty())
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The name of a pin: the repository path (`Alamofire/Alamofire`), or the
|
||||
/// spec file's name without its extension for a binary framework.
|
||||
fn name(pin: &Pin) -> String {
|
||||
match repository(pin) {
|
||||
// `host/owner/repo` without its host.
|
||||
Some(repo) => repo
|
||||
.split_once('/')
|
||||
.map_or(repo.as_str(), |(_, path)| path)
|
||||
.to_string(),
|
||||
None => {
|
||||
let file = pin.source.rsplit('/').next().unwrap_or(&pin.source);
|
||||
file.split('.').next().unwrap_or(file).to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The repository of a `github`/`git` pin as `host/owner/repo`, without
|
||||
/// scheme, user or `.git`: the identity OSV's Swift ecosystem uses.
|
||||
fn repository(pin: &Pin) -> Option<String> {
|
||||
if pin.binary {
|
||||
return None;
|
||||
}
|
||||
let source = pin.source.trim_end_matches('/');
|
||||
let source = source.strip_suffix(".git").unwrap_or(source);
|
||||
if !source.contains("://") && !source.contains('@') {
|
||||
// `github "Owner/Repo"`.
|
||||
return Some(format!("github.com/{source}"));
|
||||
}
|
||||
// `https://host/owner/repo`, `ssh://git@host/owner/repo`, `git@host:owner/repo`.
|
||||
let rest = source.split_once("://").map_or(source, |(_, rest)| rest);
|
||||
let rest = rest.split_once('@').map_or(rest, |(_, rest)| rest);
|
||||
Some(rest.replacen(':', "/", 1))
|
||||
}
|
||||
|
||||
/// A version as advisories write it: `v5.4.0` becomes `5.4.0`; anything else
|
||||
/// (a branch or commit) is kept.
|
||||
fn version(raw: &str) -> &str {
|
||||
raw.strip_prefix('v')
|
||||
.filter(|rest| rest.starts_with(|c: char| c.is_ascii_digit()))
|
||||
.unwrap_or(raw)
|
||||
}
|
||||
|
||||
/// The SBOM entry of one pin.
|
||||
fn entry(repo_id: &str, pin: &Pin) -> SbomEntry {
|
||||
let version = version(&pin.version).to_string();
|
||||
let mut entry = SbomEntry::new(
|
||||
repo_id.to_string(),
|
||||
name(pin),
|
||||
version.clone(),
|
||||
CARTHAGE_MANAGER.to_string(),
|
||||
);
|
||||
entry.purl = repository(pin).map(|repo| format!("pkg:swift/{repo}@{version}"));
|
||||
entry
|
||||
}
|
||||
|
||||
/// The `Cartfile.resolved` files under `root`, outside installed dependencies
|
||||
/// and build output.
|
||||
pub(crate) fn resolved_files(root: &Path) -> impl Iterator<Item = walkdir::DirEntry> {
|
||||
walkdir::WalkDir::new(root)
|
||||
.min_depth(1)
|
||||
.max_depth(MAX_DEPTH)
|
||||
.sort_by_file_name()
|
||||
.into_iter()
|
||||
.filter_entry(|e| {
|
||||
!(e.file_type().is_dir()
|
||||
&& SKIPPED_DIRS.contains(&e.file_name().to_string_lossy().as_ref()))
|
||||
})
|
||||
.filter_map(Result::ok)
|
||||
.filter(|e| e.file_type().is_file() && e.file_name() == RESOLVED_FILE)
|
||||
}
|
||||
|
||||
/// The Carthage components under `root`: every pin of every
|
||||
/// `Cartfile.resolved`, once.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `root` - the checked-out or unpacked source tree
|
||||
/// * `repo_id` - the target the entries belong to
|
||||
pub(crate) fn carthage_components(root: &Path, repo_id: &str) -> Vec<SbomEntry> {
|
||||
let mut out: Vec<SbomEntry> = resolved_files(root)
|
||||
.filter_map(|file| std::fs::read_to_string(file.path()).ok())
|
||||
.flat_map(|text| parse_resolved(&text))
|
||||
.map(|pin| entry(repo_id, &pin))
|
||||
.collect();
|
||||
out.sort_by(|a, b| (&a.name, &a.version).cmp(&(&b.name, &b.version)));
|
||||
out.dedup_by(|a, b| a.name == b.name && a.version == b.version);
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::expect_used)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const RESOLVED: &str = "\
|
||||
github \"Alamofire/Alamofire\" \"5.4.0\"
|
||||
github \"ReactiveX/RxSwift\" \"v6.2.0\"
|
||||
git \"https://gitlab.example.com/pumps/PumpKit.git\" \"1.3.1\"
|
||||
git \"git@gitlab.example.com:pumps/Codec.git\" \"0123456789abcdef0123456789abcdef01234567\"
|
||||
binary \"https://vendor.example.com/carthage/VendorSDK.json\" \"3.1.0\"
|
||||
# not a pin
|
||||
branch \"x\" \"y\"
|
||||
";
|
||||
|
||||
fn purls(text: &str) -> Vec<(String, String, Option<String>)> {
|
||||
parse_resolved(text)
|
||||
.iter()
|
||||
.map(|pin| entry("t", pin))
|
||||
.map(|e| (e.name, e.version, e.purl))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pins_become_swift_purls_and_binaries_have_none() {
|
||||
let some = |s: &str| Some(s.to_string());
|
||||
assert_eq!(
|
||||
purls(RESOLVED),
|
||||
vec![
|
||||
(
|
||||
"Alamofire/Alamofire".into(),
|
||||
"5.4.0".into(),
|
||||
some("pkg:swift/github.com/Alamofire/Alamofire@5.4.0")
|
||||
),
|
||||
(
|
||||
"ReactiveX/RxSwift".into(),
|
||||
"6.2.0".into(),
|
||||
some("pkg:swift/github.com/ReactiveX/RxSwift@6.2.0")
|
||||
),
|
||||
(
|
||||
"pumps/PumpKit".into(),
|
||||
"1.3.1".into(),
|
||||
some("pkg:swift/gitlab.example.com/pumps/PumpKit@1.3.1")
|
||||
),
|
||||
(
|
||||
"pumps/Codec".into(),
|
||||
"0123456789abcdef0123456789abcdef01234567".into(),
|
||||
some(
|
||||
"pkg:swift/gitlab.example.com/pumps/Codec@\
|
||||
0123456789abcdef0123456789abcdef01234567"
|
||||
)
|
||||
),
|
||||
("VendorSDK".into(), "3.1.0".into(), None),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn malformed_lines_are_skipped() {
|
||||
assert!(parse_resolved("github \"Only/Source\"\ngithub\n\"x\" \"y\"\n").is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn components_are_read_outside_installed_dependencies_once() {
|
||||
let dir = std::env::temp_dir().join(format!("cs-carthage-{}", uuid::Uuid::new_v4()));
|
||||
for path in [
|
||||
"Cartfile.resolved",
|
||||
"ios/Cartfile.resolved",
|
||||
"Carthage/Checkouts/Other/Cartfile.resolved",
|
||||
] {
|
||||
let full = dir.join(path);
|
||||
std::fs::create_dir_all(full.parent().expect("parent")).expect("mkdir");
|
||||
std::fs::write(full, "github \"Alamofire/Alamofire\" \"5.4.0\"\n").expect("write");
|
||||
}
|
||||
let components = carthage_components(&dir, "t");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
assert_eq!(components.len(), 1);
|
||||
assert_eq!(components[0].package_manager, CARTHAGE_MANAGER);
|
||||
}
|
||||
}
|
||||
@@ -86,13 +86,12 @@ const PUB: Ecosystem = Ecosystem {
|
||||
remedy: "commit the app's pubspec.lock",
|
||||
};
|
||||
|
||||
/// Carthage has a lockfile, but no SBOM tool reads it, so it is reported
|
||||
/// whether or not `Cartfile.resolved` is present.
|
||||
/// Carthage pins are read from `Cartfile.resolved` (see [`super::carthage`]).
|
||||
const CARTHAGE: Ecosystem = Ecosystem {
|
||||
manifests: &["Cartfile"],
|
||||
lockfiles: &[],
|
||||
problem: "declares Carthage dependencies, which no SBOM tool reads",
|
||||
remedy: "move them to Swift Package Manager or CocoaPods, or list them by hand",
|
||||
lockfiles: &[super::carthage::RESOLVED_FILE],
|
||||
problem: "declares Carthage dependencies but no Cartfile.resolved pins them",
|
||||
remedy: "commit Cartfile.resolved",
|
||||
};
|
||||
|
||||
const ECOSYSTEMS: [&Ecosystem; 5] = [&GRADLE, &COCOAPODS, &SWIFTPM, &PUB, &CARTHAGE];
|
||||
@@ -138,7 +137,7 @@ impl Seen {
|
||||
/// by a lockfile the SBOM reads.
|
||||
pub(crate) fn unlocked_mobile_ecosystems(root: &Path) -> Vec<UnlockedEcosystem> {
|
||||
let seen = walk(root);
|
||||
ECOSYSTEMS
|
||||
let mut out: Vec<UnlockedEcosystem> = ECOSYSTEMS
|
||||
.iter()
|
||||
.zip(seen.manifest)
|
||||
.zip(seen.locked)
|
||||
@@ -150,7 +149,31 @@ pub(crate) fn unlocked_mobile_ecosystems(root: &Path) -> Vec<UnlockedEcosystem>
|
||||
remedy: eco.remedy,
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
.collect();
|
||||
// Prebuilt Carthage frameworks are listed with their versions, but no
|
||||
// advisory database covers them.
|
||||
let binary = super::carthage::resolved_files(root).find(|file| {
|
||||
std::fs::read_to_string(file.path()).is_ok_and(|text| {
|
||||
super::carthage::parse_resolved(&text)
|
||||
.iter()
|
||||
.any(|pin| pin.binary)
|
||||
})
|
||||
});
|
||||
if let Some(file) = binary {
|
||||
out.push(UnlockedEcosystem {
|
||||
manifest: file
|
||||
.path()
|
||||
.strip_prefix(root)
|
||||
.unwrap_or(file.path())
|
||||
.to_string_lossy()
|
||||
.replace('\\', "/"),
|
||||
problem: "pins prebuilt binary frameworks, which are listed but which no \
|
||||
advisory database covers",
|
||||
remedy: "check these vendor frameworks against their vendors' security \
|
||||
advisories, or depend on their source through Swift Package Manager",
|
||||
});
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Walk `root` once, recording manifests and lockfiles of every ecosystem.
|
||||
@@ -305,9 +328,25 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn carthage_is_reported_even_with_its_resolved_file() {
|
||||
let dir = tree(&[("Cartfile", ""), ("Cartfile.resolved", "")]);
|
||||
assert_eq!(manifests(dir.path()), vec!["Cartfile"]);
|
||||
fn carthage_is_reported_without_its_resolved_file_or_with_binaries() {
|
||||
let unlocked = tree(&[("Cartfile", "")]);
|
||||
assert_eq!(manifests(unlocked.path()), vec!["Cartfile"]);
|
||||
let pinned = tree(&[
|
||||
("Cartfile", ""),
|
||||
(
|
||||
"Cartfile.resolved",
|
||||
"github \"Alamofire/Alamofire\" \"5.4.0\"\n",
|
||||
),
|
||||
]);
|
||||
assert!(manifests(pinned.path()).is_empty());
|
||||
let binary = tree(&[
|
||||
("ios/Cartfile", ""),
|
||||
(
|
||||
"ios/Cartfile.resolved",
|
||||
"binary \"https://vendor.example.com/Sdk.json\" \"3.1.0\"\n",
|
||||
),
|
||||
]);
|
||||
assert_eq!(manifests(binary.path()), vec!["ios/Cartfile.resolved"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
mod cargo_audit;
|
||||
mod carthage;
|
||||
mod gradle;
|
||||
mod mobile;
|
||||
mod nuget;
|
||||
@@ -100,6 +101,20 @@ impl SbomScanner {
|
||||
}
|
||||
}
|
||||
|
||||
// Carthage pins, which Syft does not read; a repository a Swift package
|
||||
// also pins is listed once.
|
||||
let tree = repo_path.to_path_buf();
|
||||
let target = repo_id.to_string();
|
||||
let pinned =
|
||||
tokio::task::spawn_blocking(move || carthage::carthage_components(&tree, &target))
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
for entry in pinned {
|
||||
if entry.purl.is_none() || !entries.iter().any(|e| e.purl == entry.purl) {
|
||||
entries.push(entry);
|
||||
}
|
||||
}
|
||||
|
||||
// Unity projects: the editor version and the packages `Packages/` pins.
|
||||
let tree = repo_path.to_path_buf();
|
||||
let target = repo_id.to_string();
|
||||
|
||||
@@ -736,14 +736,18 @@
|
||||
"languages": [
|
||||
"java",
|
||||
"kotlin",
|
||||
"csharp"
|
||||
"csharp",
|
||||
"swift",
|
||||
"objc"
|
||||
],
|
||||
"cwe": [],
|
||||
"rules": [
|
||||
"android-sdk-end-of-support",
|
||||
"unity-editor-end-of-support"
|
||||
"unity-editor-end-of-support",
|
||||
"ios-deployment-target-end-of-support",
|
||||
"swift-version-end-of-support"
|
||||
],
|
||||
"check": "The platform a product is built for must still receive security updates; an Android API level or a Unity editor release out of support violates it."
|
||||
"check": "The platform a product is built for, and the tools it is built with, must still receive security updates; an Android API level, a Unity editor release or an iOS deployment target out of support, or a Swift version no supported Xcode builds, violates it."
|
||||
}
|
||||
],
|
||||
"note": null,
|
||||
|
||||
+12
-4
@@ -19,15 +19,19 @@ Prüfwerk builds the SBOM during each scan:
|
||||
- **Mobile apps** -- the lockfiles of Android, iOS and Flutter apps, wherever
|
||||
they sit in the tree (`android/`, `ios/`, an Xcode project): `gradle.lockfile`,
|
||||
`Podfile.lock`, `Package.resolved` (also the one inside
|
||||
`*.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/`) and `pubspec.lock`.
|
||||
`*.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/`), `Cartfile.resolved`
|
||||
and `pubspec.lock`. A Carthage pin of a repository is matched like the Swift
|
||||
package of the same repository; a prebuilt `binary` framework is listed with
|
||||
its version, but no advisory database covers it, which the scan says under
|
||||
**Nicht ausgeführt**.
|
||||
Gradle writes `gradle.lockfile` only with dependency locking switched on
|
||||
(`dependencyLocking { lockAllConfigurations() }`, then
|
||||
`./gradlew dependencies --write-locks`). Without it, Prüfwerk reads the
|
||||
direct dependencies from the build files (`build.gradle(.kts)`, versions in
|
||||
`ext` variables, `gradle.properties` and `gradle/libs.versions.toml`), but
|
||||
only those that ship with the app and have an exact version; what they pull
|
||||
in stays unknown. In that case, and for Carthage, whose
|
||||
`Cartfile.resolved` no tool reads, the scan reports the manifest under
|
||||
in stays unknown. In that case, and for a `Cartfile` without its
|
||||
`Cartfile.resolved`, the scan reports the manifest under
|
||||
**Nicht ausgeführt** and the SBOM requirements of the CRA view are
|
||||
**Nicht bewertet**: an app whose dependencies are unknown is not shown as
|
||||
clean.
|
||||
@@ -58,7 +62,11 @@ nowhere readable. Prüfwerk reports it as a finding (**Legacy build system: the
|
||||
SBOM cannot be determined**, with the migration as the remedy) and lists it
|
||||
under **Nicht ausgeführt**, so the SBOM requirements are **Nicht bewertet**
|
||||
rather than clean. An Android API level below 29 or a Unity release out of
|
||||
support is a finding of its own.
|
||||
support is a finding of its own, and so is, in an Xcode project, an iOS
|
||||
deployment target below 15 (the app then installs on iOS releases that receive
|
||||
no security updates) or a `SWIFT_VERSION` below 4, which no supported Xcode
|
||||
builds. Which Xcode builds an app is not recorded in the repository and is not
|
||||
judged.
|
||||
|
||||
Firmware images, container images and app packages are not unpacked yet; their
|
||||
components come from the source code.
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [
|
||||
"sbom_dependencies"
|
||||
],
|
||||
"sbom": [
|
||||
"carthage:Alamofire/Alamofire@4.8.2",
|
||||
"carthage:PumpSDK@3.1.0",
|
||||
"carthage:grpc/grpc-swift@1.0.0"
|
||||
],
|
||||
"findings": [],
|
||||
"cves": [
|
||||
"GHSA-2jx2-qcm4-rf9h",
|
||||
"GHSA-4rhq-vq24-88gw",
|
||||
"GHSA-r6ww-5963-7r95",
|
||||
"GHSA-rxmj-hg9v-vp3p",
|
||||
"ios-deployment-target-end-of-support",
|
||||
"swift-version-end-of-support"
|
||||
]
|
||||
}
|
||||
@@ -12,6 +12,7 @@ as a source archive. They prove that no mobile app ends with "0 packages,
|
||||
| `ios-cocoapods` | `Podfile.lock` (AFNetworking 2.5.1) | 2 pods; a recorded `cve_lookup` skip, as OSV has no CocoaPods advisories |
|
||||
| `ios-spm-xcode` | `Package.resolved` inside the Xcode project (swift-nio-http2 1.19.0) | 1 Swift component with its advisories (needs the purl in repository form) |
|
||||
| `ios-spm-unlocked` | nothing: the Xcode project names a Swift package | none; a recorded `sbom_dependencies` skip naming `project.pbxproj` |
|
||||
| `ios-carthage-legacy` | `Cartfile.resolved` (Alamofire 4.8.2, grpc-swift 1.0.0, a binary vendor framework); an Xcode project at iOS 10 and Swift 3 | both repositories as Swift components, grpc-swift with its advisories; the binary framework listed without; a recorded `sbom_dependencies` skip naming the binary pin; the iOS deployment target and Swift version lifecycle findings |
|
||||
| `flutter` | `pubspec.lock` (dio 3.0.10); the Android host app is unlocked | the Dart packages and the host app's direct Gradle dependency; a recorded `sbom_dependencies` skip |
|
||||
| `react-native` | `package-lock.json`; neither `ios/Podfile` nor the Gradle app is locked | the npm packages; a recorded `sbom_dependencies` skip |
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
github "Alamofire/Alamofire" ~> 4.0
|
||||
github "grpc/grpc-swift" == 1.0.0
|
||||
binary "https://pump-vendor.example.com/carthage/PumpSDK.json" ~> 3.1
|
||||
@@ -0,0 +1,3 @@
|
||||
binary "https://pump-vendor.example.com/carthage/PumpSDK.json" "3.1.0"
|
||||
github "Alamofire/Alamofire" "4.8.2"
|
||||
github "grpc/grpc-swift" "1.0.0"
|
||||
@@ -0,0 +1,26 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
A1000001 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.pumpremote;
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
A1000002 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.pumpremote;
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
};
|
||||
rootObject = A1000000;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import UIKit
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
var window: UIWindow?
|
||||
}
|
||||
@@ -624,6 +624,25 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "mobile-ios-carthage-legacy",
|
||||
"name": "iOS · Carthage and an old Xcode project",
|
||||
"target_type": "ios_app",
|
||||
"description": "Uploaded as a source archive. A Swift 3 app with an iOS 10 deployment target that pins Alamofire 4.8.2, grpc-swift 1.0.0 and a prebuilt vendor framework in Cartfile.resolved. The repositories must appear as Swift purls (pkg:swift/github.com/grpc/grpc-swift@1.0.0) so OSV matches grpc-swift's advisories, the binary framework must be listed and named under sbom_dependencies, and both iOS lifecycle findings must be raised.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
"upload": "fixtures/nightly/mobile/ios-carthage-legacy"
|
||||
}
|
||||
],
|
||||
"expect": {
|
||||
"sast_rule_ids": [
|
||||
"ios-deployment-target-end-of-support",
|
||||
"swift-version-end-of-support"
|
||||
],
|
||||
"min_sbom_components": 3
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "mobile-flutter",
|
||||
"name": "Flutter app",
|
||||
|
||||
Reference in new issue
Block a user