test(audit-ship e2e): wait on the metrics file's content, not one read after the stream grows #312
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- This is an auto-generated comment: rate limited by coderabbit.ai -->
[!WARNING]
## Review limit reached
> You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.
> Next included review available in 52 minutes.
> Check out review usage here.
> <details>
<summary>View limit details</summary>
> Limit details: You’ve used the included review currently available.
> Learn how review limits work.
> Review configuration:
> <details>
<summary>⚙️ Run configuration</summary>
> - Configuration used: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID: 47d6a69a-caf5-47ae-9cdb-f42e8621e932> </details>
> <details>
<summary>📥 Commits</summary>
> Reviewing files that changed from the base of the PR and between 635e187df72efdc1b4972ef2afce76bae192ddb1 and f90457b8a35bc08c2841d217695385a6c02d80e5.
> </details>
> <details>
<summary>📒 Files selected for processing (1)</summary>
> * e2e/audit-ship-systemd.py> </details>
> </details>
<!-- end of auto-generated comment: rate limited by coderabbit.ai -->
<!-- autopilot:start -->
<!-- autopilot:end -->
<!-- tips_start -->
---
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.
<details>
<summary>❤️ Share</summary>
</details>
<sub>Comment @coderabbitai help to get the list of available commands.</sub>
<!-- tips_end -->
🟡 Medium · insecure file permissions <code>e2e/audit-ship-systemd.py:135</code>
These permissions '0o755' are widely permissive and grant access to more people than may be necessary. A good default is '0o644' which gives read and write access to yourself and read access to everyone else.
_Pre-existing — not introduced by this diff. This pull request changes the file, but not line 135, so the finding cannot be commented on the line itself. Resolve this thread once it is fixed or judged not to apply._
<!-- sentinel:finding:37f79a4e5c40e488:26a7b2040664ec1b -->
🟡 Medium · insecure file permissions <code>e2e/audit-ship-systemd.py:142</code>
These permissions '0o755' are widely permissive and grant access to more people than may be necessary. A good default is '0o644' which gives read and write access to yourself and read access to everyone else.
_Pre-existing — not introduced by this diff. This pull request changes the file, but not line 142, so the finding cannot be commented on the line itself. Resolve this thread once it is fixed or judged not to apply._
<!-- sentinel:finding:671d1ca8d39b91e8:26a7b2040664ec1b -->
🟡 Medium · insecure file permissions <code>e2e/audit-ship-systemd.py:255</code>
These permissions '0o755' are widely permissive and grant access to more people than may be necessary. A good default is '0o644' which gives read and write access to yourself and read access to everyone else.
_Pre-existing — not introduced by this diff. This pull request changes the file, but not line 255, so the finding cannot be commented on the line itself. Resolve this thread once it is fixed or judged not to apply._
<!-- sentinel:finding:84ccad4764979faa:26a7b2040664ec1b -->
🛡️ Sentinel review — 3 pre-existing issue(s) in changed files, on lines this diff does not add.
<details><summary>📋 Walkthrough</summary>
0 file(s) with findings on changed lines.
| Signal | Count | Confidence |
|---|---|---|
| Tool-proven findings | 0 | deterministic scanners |
| Model findings (corroborated) | 0 | independent panel agreed |
| Model findings (unverified) | 0 | shown collapsed, not inline |
| Nitpicks & observations | 0 | collapsed, no action needed |
<!-- flynn:rid:om-688168c590044e3c92456775c8bd3c6d -->
_Reviewed by <code>flynn</code> · panel requested, not applied — fell back to the single-model gate._
</details>
<!-- sentinel-pr-review engine=4f28185e72a56658a0a5c68cead30c12f60eea85-main -->
<!-- sentinel:scan-report -->
<details><summary>📊 Scan report — every finding in the changed files, ranked, plus the scan summary</summary>
🛡️ Sentinel PR review
1 file(s) changed · 3 introduced by this diff (secrets+SAST) · dependencies unchanged — SCA/CVE not re-scanned. _Advisory — the fail-closed gate is the post-merge pentest._
Findings — ranked by criticality
e2e/audit-ship-systemd.py:135 — insecure file permissions These permissions 0o755 are widely permissive and grant access to more people than may be necessary. A good default is 0o644 which gives read and write access to yourself and read access to everyone else. _(CWE-276)_e2e/audit-ship-systemd.py:142 — insecure file permissions These permissions 0o755 are widely permissive and grant access to more people than may be necessary. A good default is 0o644 which gives read and write access to yourself and read access to everyone else. _(CWE-276)_e2e/audit-ship-systemd.py:255 — insecure file permissions These permissions 0o755 are widely permissive and grant access to more people than may be necessary. A good default is 0o644 which gives read and write access to yourself and read access to everyone else. _(CWE-276)_🤖 Code review (Flynn)
No issues found.
<details><summary>Scan summary</summary>
| Category | Scope | Findings |
|---|---|---|
| Secrets | this diff | 0 |
| Static analysis | changed files | 3 |
| Dependencies + IaC | skipped (no manifest changed) | 0 |
| Known CVEs | skipped (no manifest changed) | 0 |
</details>
</details>
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
0o755 on the trail's directory (/var/log/regalia stands in, a directory): the trail inside it is 0640 in its reader group, which this test checks. Not a line this PR changes. A directory mode, not a finding: resolving (with its duplicates).
0o755 on the shipper binary: it must be executable. Not a line this PR changes. A directory mode, not a finding: resolving (with its duplicates).
0o755 on the test's work directory, which the service users must traverse. Not a line this PR changes. A directory mode, not a finding: resolving (with its duplicates).
jobordu
Fixes #311. The audit-ship e2e's metrics check failed once on #304's run and passed on re-run (reported by regalia-kms-24 and 3e).
Cause: the shipper writes
/var/lib/regalia-audit-ship/sync.promafter the collector's receipt comes back, which is after the collector's stream has grown. Each check waited for the stream to reach N lines and then read the metrics file once, so it could still see the previous pass's numbers.Fix: the three metrics checks now wait, for up to 30 s each, until the file holds exactly what they assert:
Only the test changes.
Read by regalia-kms-24 at f90457b, no hold. Its optional nit, that the shipper should write the textfile temp-then-rename, is already true: cmd/regalia-audit-ship/main.go:427-447 writes with CreateTemp in the same directory, then Rename.
🤖 Generated with Claude Code