Skip to content

Add Swift Package Manager scanner - #31

Merged
gr-markin merged 3 commits into
mainfrom
feature/swift-package-manager-scan
Sep 25, 2026
Merged

gr-markin merged 3 commits into
mainfrom
feature/swift-package-manager-scan

Conversation

@jthDEV

@jthDEV jthDEV commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Ports dependency resolution from the now-retired ts-spm plugin into ts-scan's own Scanner interface, replacing the need for a separate plugin
  • Detects Package.swift and parses the JSON tree produced by swift package show-dependencies --format json into ts-scan's Dependency/DependencyScan model, using the swift purl type as key/purl prefix
  • Registers SwiftScanner alongside the other package-manager scanners; --swift:ignore, --swift:executable and --swift:forward become available like for the other PM-backed scanners

Dependencies added

None — uses only the swift executable already required by Swift Package Manager projects.

Test plan

  • pytest tests/test_swift.py — accepts()/scan() unit tests with a mocked swift package show-dependencies JSON tree (including diamond-dependency de-duplication)
  • pytest tests/ — full existing suite still passes

@jthDEV
jthDEV requested a review from gr-markin August 25, 2026 23:04
Comment thread tests/test_swift.py Dismissed
Comment thread tests/test_swift.py Dismissed
Comment thread tests/test_swift.py Dismissed
Comment thread tests/test_swift.py Fixed
Comment thread tests/test_swift.py Dismissed
Comment thread tests/test_swift.py Dismissed
Comment thread tests/test_swift.py Dismissed
Comment thread tests/test_swift.py Dismissed
Comment thread tests/test_swift.py Fixed
Comment thread tests/test_swift.py Fixed
@jthDEV jthDEV mentioned this pull request Sep 22, 2026
2 tasks done
jthDEV and others added 3 commits September 22, 2026 14:46
Ports the dependency resolution logic from the retired ts-spm plugin
(https://github.com/TrustSource/ts-spm) into ts-scan's own Scanner
interface. Detects Package.swift and parses the JSON tree produced by
`swift package show-dependencies --format json`.
The branch predates "Return an iterable from scanner implementations",
so scan() still returned an optional single scan, which makes
_execute_scans fail with "'DependencyScan' object is not iterable".

Returns a list of scans instead, and an empty list when the swift
executable produces no output. The unit tests called scan() directly and
therefore did not catch this, so they now assert on the returned
sequence.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The list of supported ecosystems in the description had fallen behind
and named only a fraction of the available scanners. Names all of them,
including the ones added in parallel (Composer, CocoaPods, Swift Package
Manager), and adds a table stating for each ecosystem how a project is
detected, where the resolved graph comes from and which executable is
required.

The distinction matters in CI: scanners reading an already resolved
lockfile (CocoaPods, Composer and Cargo with a committed lockfile, VB6)
need neither a toolchain nor network access.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jthDEV
jthDEV force-pushed the feature/swift-package-manager-scan branch from 31216f0 to 2bf7364 Compare September 22, 2026 12:47
@jthDEV

jthDEV commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (the branch had drifted 11 commits behind) and updated by force-push.

Conflicts resolved: scanner registry in src/ts_scan/__init__.py, the PM option list in README.md, and the [Unreleased] section in CHANGELOG.md.

The rebase surfaced a real defect. This branch predates Return an iterable from scanner implementations, so scan() still returned an optional single DependencyScan, which makes _execute_scans fail with 'DependencyScan' object is not iterable. The same defect existed on #32. Commit 7780456 returns a list of scans (empty when swift produces no output) and adapts the tests, which called scan() directly and therefore never hit it.

README (as the last of the three PRs). Commit 2bf7364 brings the ecosystem documentation up to date. The description named only a fraction of the available scanners; it now names all of them and adds a table stating per ecosystem how a project is detected, where the resolved graph comes from, and which executable is required — including Composer (#38) and CocoaPods (#32). The table makes explicit which scanners work from a committed lockfile alone, i.e. without toolchain or network access in CI.

Therefore merge this one last: #38 → #32 → #31. The README and option list in this PR already describe --composer:* and --cocoapods:ignore, which only exist once the other two have landed. If the order changes, this branch needs another rebase first.

Full suite green (43 passed).

🤖 Generated with Claude Code

Comment thread tests/test_swift.py Dismissed
Comment thread tests/test_swift.py Dismissed
Comment thread tests/test_swift.py Dismissed
@gr-markin
gr-markin merged commit db1bc75 into main Sep 25, 2026
6 checks passed
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.

3 participants