Skip to content

Auto install Cocoapods when Podfile.lock not exist#723

Open
attiasas wants to merge 13 commits intojfrog:devfrom
attiasas:fix_cocoapods_auto_install
Open

Auto install Cocoapods when Podfile.lock not exist#723
attiasas wants to merge 13 commits intojfrog:devfrom
attiasas:fix_cocoapods_auto_install

Conversation

@attiasas
Copy link
Copy Markdown
Collaborator

@attiasas attiasas commented Apr 12, 2026

  • The pull request is targeting the dev branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....
  • All static analysis checks passed.
  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • Updated the Contributing page / ReadMe page / CI Workflow files if needed.
  • All changes are detailed at the description. if not already covered at JFrog Documentation, new documentation have been added.

Improvement(cocoapods): auto-install when Podfile.lock is missing

Summary
CocoaPods BOM / dependency-tree generation now detects a missing Podfile.lock and runs pod install (unless SkipAutoInstall is enabled), so audits can proceed without a pre-generated lockfile. CocoaPods test fixtures are reorganized under cocoapods-project, and a new cocoapods-no-lock-file sample project supports integration coverage. The hidden skip-auto-install flag documentation is generalized to reflect support beyond Yarn/NPM only.

Changes

  • sca/bom/buildinfo/technologies/cocoapods: After resolving the pod executable, if Podfile.lock is absent and auto-install is allowed, run pod install; if auto-install is skipped, return a clear error. Introduce descriptorFileName / lockFileName constants; split getPodExecPath from getPodVersionAndExecPath and improve version-check error wrapping (podcommand.go, cocoapods.go).
  • cli/docs/flags.go: Widen SkipAutoInstall help text to “some package managers.”
  • Tests / fixtures: Move existing Podfile / Podfile.lock under tests/testdata/.../cocoapods/cocoapods-project; add cocoapods-no-lock-file fixture (Podfile + minimal Xcode workspace files). Point unit tests at the new path (cocoapods_test.go). Add TestXrayAuditCocoapodsNoLockFile and parameterize testXrayAuditCocoapods by project name (audit_test.go).
  • git_test.go: Adjust expected violation applicability / scan counts in two JAS-related git audit tests.

Testing

  • TestXrayAuditCocoapods / TestXrayAuditCocoapodsNoLockFile (latter skipped on Windows in code), and full go test ./... / CI as usual.

Notes

  • Auto-install assumes a working pod on PATH and a suitable host toolchain (the new audit test skips on Windows for that reason). SkipAutoInstall preserves the previous strict behavior when no lockfile exists.
  • git_test.go expectation changes are included in this branch; confirm they match the intended Xray/JAS baseline for your environment if those tests are sensitive to server or graph versions.

@attiasas attiasas requested a review from a team April 12, 2026 07:01
@attiasas attiasas added the bug Something isn't working label Apr 12, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Apr 13, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Apr 13, 2026
@attiasas attiasas added improvement Automatically generated release notes and removed bug Something isn't working labels Apr 19, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Apr 19, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Apr 19, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Apr 20, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Apr 20, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label May 4, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label May 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

👍 Frogbot scanned this pull request and did not find any new security issues.


err = fmt.Errorf("failed while retrieving pod path: %s", err.Error())
return
}
// Check if lock file exists, if not run 'pod install'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If os.Stat(lockFilePath) fails for a reason other than “not exist” (permissions, I/O), you skip the branch and fall through to GetDependenciesData. in those cases the failure mode may look like a missing lockfile. Consider returning a clearer error when err != nil && !os.IsNotExist(err).

lockFilePath := filepath.Join(currentDir, lockFileName)
if _, err := os.Stat(lockFilePath); os.IsNotExist(err) {
if params.SkipAutoInstall {
return nil, nil, fmt.Errorf("the Podfile.lock file was not found and skip auto install is enabled")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can write "skip-auto-install" to be aligned with the real flag name.

if params.SkipAutoInstall {
return nil, nil, fmt.Errorf("the Podfile.lock file was not found and skip auto install is enabled")
}
if _, err = runPodCmd(podExecPath, currentDir, []string{"install"}); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Auto pod install writes into the project (Pods/, Podfile.lock). Worth a one-line note in the PR description or docs so users expect workspace mutation (similar to npm/yarn auto-install).

Comment thread audit_test.go
securityIntegrationTestUtils.InitAuditCocoapodsTest(t, scangraph.CocoapodsScanMinXrayVersion)
if coreutils.IsWindows() {
t.Skip("Skipping: CocoaPods auto-install (pod install) requires macOS/Linux with Xcode.")
return
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

redundant "return"

Comment thread cli/docs/flags.go
OutputDir: components.NewStringFlag(OutputDir, "Target directory to save partial results to.", components.SetHiddenStrFlag()),
UploadRepoPath: components.NewStringFlag(UploadRepoPath, "Artifactory repository name or path to upload the cyclonedx file to. If no name or path are provided, a local generic repository will be created which will automatically be indexed by Xray.", components.WithStrDefaultValue("import-cdx-scan-results")),
SkipAutoInstall: components.NewBoolFlag(SkipAutoInstall, "Set to true to skip auto-install of dependencies in un-built modules. Currently supported for Yarn and NPM only.", components.SetHiddenBoolFlag()),
SkipAutoInstall: components.NewBoolFlag(SkipAutoInstall, "Set to true to skip auto-install of dependencies in un-built modules. Currently supported only for some package managers.", components.SetHiddenBoolFlag()),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

“Some package managers” is vague for troubleshooting. Even for a hidden flag, naming Yarn, npm, and CocoaPods (or “including CocoaPods”) may be more useful .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Automatically generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants