Skip to content

chore: check in pubspec.lock for supply chain security#350

Merged
marandaneto merged 4 commits intomainfrom
chore/check-in-pubspec-lock
Mar 31, 2026
Merged

chore: check in pubspec.lock for supply chain security#350
marandaneto merged 4 commits intomainfrom
chore/check-in-pubspec-lock

Conversation

@marandaneto
Copy link
Copy Markdown
Member

@marandaneto marandaneto commented Mar 31, 2026

💡 Motivation and Context

Without lock files checked in, every CI run resolves fresh dependencies. If a transitive dependency gets compromised between runs, CI silently pulls the malicious version with no diff to review.

While the Dart convention recommends not checking in lock files for libraries (to test compatibility breadth), this trades security for flexibility. We can have both by:

  • Checking in lock files for CI reproducibility
  • Excluding pubspec.lock from the published package via .pubignore so consumers resolve their own versions
  • Periodically running flutter pub upgrade / pod update to test newer versions explicitly

What this gives us

  • Pinned transitive deps in CI — no surprise resolutions
  • sha256 content hash verification — pub verifies hashes on every flutter pub get, catching tampered packages (Dart 2.19+)
  • CocoaPods pinningPodfile.lock pins native iOS/macOS transitive deps for the example app
  • Explicit updates — dependency changes only happen when someone explicitly updates and commits the diff, making them reviewable
  • No impact on consumers.pubignore ensures the lock file is excluded from the published package

💚 How did you test it?

  • Ran flutter pub get — resolves successfully with the checked-in lock file
  • Verified pubspec.lock contains sha256 hashes for all hosted packages
  • Verified Podfile.lock files contain pinned versions and checksums

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

Changes

  • Removed pubspec.lock from .gitignore (was listed twice, both removed)
  • Removed Podfile.lock from .gitignore
  • Added pubspec.lock to source control (Dart/Flutter dependencies)
  • Added example/ios/Podfile.lock to source control (iOS CocoaPods dependencies)
  • Added example/macos/Podfile.lock to source control (macOS CocoaPods dependencies)
  • Added posthog_flutter/.pubignore to exclude lock file from published package

…security

- Remove pubspec.lock from .gitignore
- The lock file includes sha256 content hashes (Dart 2.19+) which pub
  verifies on every resolve, catching tampered packages
- CI now uses pinned transitive deps instead of resolving fresh each run
- To update dependencies, run 'flutter pub upgrade' and commit the diff
@marandaneto marandaneto requested a review from a team as a code owner March 31, 2026 11:26
Consumers should resolve their own dependency versions, not use ours.
The lock file stays in the repo for CI reproducibility and hash verification.
Pin CocoaPods transitive dependencies for CI reproducibility.
The example is an app (not a library), so lock files should be tracked.
@dustinbyrne
Copy link
Copy Markdown
Contributor

macOS lockfile stale? CI is failing

@marandaneto
Copy link
Copy Markdown
Member Author

macOS lockfile stale? CI is failing

prob, have to check, works on my machine :D

@marandaneto
Copy link
Copy Markdown
Member Author

macOS lockfile stale? CI is failing

done

@marandaneto marandaneto enabled auto-merge (squash) March 31, 2026 16:57
@marandaneto marandaneto merged commit 33ef777 into main Mar 31, 2026
19 checks passed
@marandaneto marandaneto deleted the chore/check-in-pubspec-lock branch March 31, 2026 16:59
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