Skip to content

Add CocoaPods scanner - #32

Open
jthDEV wants to merge 1 commit into
mainfrom
feature/cocoapods-scan
Open

Add CocoaPods scanner#32
jthDEV wants to merge 1 commit into
mainfrom
feature/cocoapods-scan

Conversation

@jthDEV

@jthDEV jthDEV commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a CocoaPodsScanner that parses the fully resolved dependency graph directly from Podfile.lock (PODS, DEPENDENCIES, SPEC CHECKSUMS sections) — no pod executable invocation needed since the lockfile is already resolved
  • Uses the cocoapods purl type as key/purl prefix; per-pod checksums from SPEC CHECKSUMS are attached to each Dependency
  • Registers CocoaPodsScanner alongside the other package-manager scanners; --cocoapods:ignore becomes available like for the other PM scanners

Dependencies added

  • PyYAML~=6.0 — to parse the YAML-formatted Podfile.lock (was already present as a transitive dependency of spdx-tools, now declared explicitly since ts-scan relies on it directly)

Test plan

  • pytest tests/test_cocoapods.py — accepts()/scan() unit tests against a representative Podfile.lock fixture, including a subspec dependency (SDWebImage/Core) and checksum propagation
  • pytest tests/ — full existing suite still passes

Parses the resolved dependency graph directly from Podfile.lock (PODS,
DEPENDENCIES and SPEC CHECKSUMS sections). No pod executable is
required since the lockfile is already fully resolved.

Adds PyYAML as an explicit dependency for parsing the lockfile.
@jthDEV
jthDEV requested a review from gr-markin August 25, 2026 23:05
Comment thread tests/test_cocoapods.py
def test_accepts_requires_podfile_lock(tmp_path):
scanner = CocoaPodsScanner()

assert not scanner.accepts(tmp_path)
Comment thread tests/test_cocoapods.py

(tmp_path / 'Podfile.lock').write_text(PODFILE_LOCK)

assert scanner.accepts(tmp_path)
Comment thread tests/test_cocoapods.py
scanner = CocoaPodsScanner()
scan = scanner.scan(project)

assert scan is not None
Comment thread tests/test_cocoapods.py
scan = scanner.scan(project)

assert scan is not None
assert scan.module == 'MyApp'
Comment thread tests/test_cocoapods.py

assert scan is not None
assert scan.module == 'MyApp'
assert scan.moduleId == 'cocoapods:MyApp'
Comment thread tests/test_cocoapods.py
assert alamofire.key == 'cocoapods:Alamofire'

sdwebimage = next(d for d in root.dependencies if d.name == 'SDWebImage')
assert sdwebimage.versions == ['5.15.5']
Comment thread tests/test_cocoapods.py

sdwebimage = next(d for d in root.dependencies if d.name == 'SDWebImage')
assert sdwebimage.versions == ['5.15.5']
assert [d.name for d in sdwebimage.dependencies] == ['SDWebImage/Core']
Comment thread tests/test_cocoapods.py
assert [d.name for d in sdwebimage.dependencies] == ['SDWebImage/Core']

core = sdwebimage.dependencies[0]
assert core.versions == ['5.15.5']
Comment thread tests/test_cocoapods.py

core = sdwebimage.dependencies[0]
assert core.versions == ['5.15.5']
assert core.checksum == '750adf017a716fe6f235d0c8d95406e358be216'
Comment thread tests/test_cocoapods.py

scanner = CocoaPodsScanner()

assert scanner.scan(project) is None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants