Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Package.resolved swift files support #4932

Merged
merged 9 commits into from
Aug 23, 2023

Conversation

DmitriyLewen
Copy link
Contributor

@DmitriyLewen DmitriyLewen commented Aug 3, 2023

Description

Add Package.resolved files support.

Example of work:

➜  trivy fs Package.resolved
2023-08-23T15:44:40.465+0600    INFO    Vulnerability scanning is enabled
2023-08-23T15:44:40.465+0600    INFO    Secret scanning is enabled
2023-08-23T15:44:40.465+0600    INFO    If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2023-08-23T15:44:40.465+0600    INFO    Please see also https://aquasecurity.github.io/trivy/dev/docs/scanner/secret/#recommendation for faster secret detection
2023-08-23T15:44:40.471+0600    INFO    Number of language-specific files: 1
2023-08-23T15:44:40.471+0600    INFO    Detecting swift vulnerabilities...

Package.resolved (swift)

Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 1, HIGH: 0, CRITICAL: 0)

┌────────────────────────────┬───────────────┬──────────┬────────┬───────────────────┬────────────────────────┬────────────────────────────────────────────────────────┐
│          Library           │ Vulnerability │ Severity │ Status │ Installed Version │     Fixed Version      │                         Title                          │
├────────────────────────────┼───────────────┼──────────┼────────┼───────────────────┼────────────────────────┼────────────────────────────────────────────────────────┤
│ github.com/apple/swift-nio │ CVE-2022-3215 │ MEDIUM   │ fixed  │ 2.41.0            │ 2.29.1, 2.39.1, 2.42.0 │ SwiftNIO vulnerable to Improper Neutralization of CRLF │
│                            │               │          │        │                   │                        │ Sequences in HTTP Headers ('HTTP...                    │
│                            │               │          │        │                   │                        │ https://avd.aquasec.com/nvd/cve-2022-3215              │
└────────────────────────────┴───────────────┴──────────┴────────┴───────────────────┴────────────────────────┴────────────────────────────────────────────────────────┘

Related issues

Related PRs

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@DmitriyLewen DmitriyLewen changed the title feat(swift): add Package.resolved files support feat: add Package.resolved swift files support Aug 15, 2023
@DmitriyLewen DmitriyLewen self-assigned this Aug 17, 2023
Copy link
Collaborator

@knqyf263 knqyf263 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 35 to 37
func (a swiftLockAnalyzer) Required(_ string, fileInfo os.FileInfo) bool {
return fileInfo.Name() == types.SwiftResolved
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think other analyzers use filePath.

Suggested change
func (a swiftLockAnalyzer) Required(_ string, fileInfo os.FileInfo) bool {
return fileInfo.Name() == types.SwiftResolved
}
func (a swiftLockAnalyzer) Required(filePath string, _ os.FileInfo) bool {
return path.Base(filePath) == types.SwiftResolved
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm.. i don't know why i used FileInfo...
Thanks! Changed in 9d1e8b6

@DmitriyLewen
Copy link
Contributor Author

Package.Resolved files contain package names (e.g. https://github.com/aquasecurity/go-dep-parser/blob/e39b9645d9b842013a443b800af87608f010a532/pkg/swift/swift/testdata/happy-v1-Package.resolved#L5).
But Package.swift files don't have names. To add dependencies you need to use URL in Package.swift file.

We usually use <pkg_name>@<version> schema for ID.
But use of package name can be confusing.

Peghaps we can use <URL>@<version> for Package.Resolved.

@DmitriyLewen DmitriyLewen marked this pull request as ready for review August 23, 2023 09:11
@knqyf263
Copy link
Collaborator

knqyf263 commented Aug 23, 2023

We already use <URL>@<version> schema for Go like github.com/aquasecurity/[email protected]. Can't we do the same for Swift?

@DmitriyLewen
Copy link
Contributor Author

DmitriyLewen commented Aug 23, 2023

You are right. I will add this.

UPD: added changes in 3479840

@knqyf263 knqyf263 added this pull request to the merge queue Aug 23, 2023
Merged via the queue into aquasecurity:main with commit ef70d20 Aug 23, 2023
11 checks passed
@DmitriyLewen DmitriyLewen deleted the feat/swift-package-resolved branch August 24, 2023 03:04
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.

add support Swift Package Manager
2 participants