fix(falcon): preserve AID across rebuilds - #1055
Conversation
…odes Replace rm -rf + cp with rsync --exclude to keep falconstore intact
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the Falcon sensor's initialization process within NixOS to ensure its persistent state is maintained across system rebuilds. By switching from a full directory removal and copy to a more granular synchronization method, the sensor's unique identifier and configuration are preserved, eliminating the issue of duplicate host registrations and unnecessary license consumption. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
You do not have enough credits to review this pull request. Please purchase more credits to continue. |
📝 WalkthroughWalkthroughReplaces removal and copying of the CrowdStrike directory with rsync-based synchronization that updates files from the nix store to /opt/CrowdStrike while excluding runtime state files (falconstore, falconstore.bak, CsConfig) and maintaining ownership settings. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Mesa DescriptionTL;DRPreserved Falcon sensor AID across NixOS rebuilds to prevent duplicate Kolide host registrations. What changed?
Description generated by Mesa. Update settings |
There was a problem hiding this comment.
Code Review
This pull request correctly addresses an issue where the Falcon sensor's Agent ID (AID) was not preserved across NixOS rebuilds, which caused duplicate host registrations. The change from a destructive rm -rf and cp -a to an rsync with exclusions for state files is a good solution. However, I've found one potential issue with the new rsync command that could lead to incorrect directory permissions on /opt/CrowdStrike, which I've detailed in a comment. With that one change, this PR should be good to merge.
| ${pkgs.rsync}/bin/rsync -a --delete \ | ||
| --exclude=falconstore \ | ||
| --exclude=falconstore.bak \ | ||
| --exclude=CsConfig \ | ||
| "${falcon}/opt/CrowdStrike/" /opt/CrowdStrike/ |
There was a problem hiding this comment.
The rsync -a command includes the -p (--perms) flag, which causes the destination directory's permissions to be updated to match the source. This could override the 0770 permissions set on /opt/CrowdStrike by the install -d command on line 25, potentially making it world-readable depending on the permissions in the Nix store. This is a change in behavior from the previous cp -a .../. .../ command, which does not affect the target directory's permissions.
To ensure /opt/CrowdStrike retains its restrictive permissions, please re-apply them after the rsync command by adding:
chmod 0770 /opt/CrowdStrikeThis should be placed after the rsync command.
There was a problem hiding this comment.
Pull request overview
Updates the Falcon sensor initialization in the matic NixOS host module to preserve the sensor’s runtime identity state across rebuilds, avoiding unintended re-registration and duplicate license seat consumption.
Changes:
- Replaces a destructive
/opt/CrowdStrikewipe-and-copy with anrsync --deletesync from the Nix store. - Excludes
falconstore,falconstore.bak, andCsConfigfrom sync to preserve Falcon runtime state (including AID).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Summary
rm -rf+cp -awithrsync --delete --excludein Falcon sensor init scriptfalconstore,falconstore.bak, andCsConfigruntime state files across NixOS rebuildsTest plan
nixos-rebuild switchcompletes successfullysudo /opt/CrowdStrike/falconctl -g --aidshows the same AID before and after rebuildSummary by cubic
Preserves the CrowdStrike Falcon AID and runtime state across NixOS rebuilds to prevent sensor re-registration and duplicate Kolide seats. Switches the init script to
rsync -a --deletewith excludes for falconstore, falconstore.bak, and CsConfig under /opt/CrowdStrike.Written for commit a52704c. Summary will update on new commits.