Repository navigation
refactor(analytics): move analyze_diff's halves out so the file can take its security fix (#16186, #16179) - #16212
Merged
Merged
Conversation
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 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 |
Contributor
✅ SSOT Configuration Compliance: Passing🎉 No new hardcoded values of either class — Known backlog in |
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thinking Path
analyze_diffwas 117 body lines against the 65 threshold, and theFunction Length Check(#620) is whole-file — so it blocked every change toanalytics_code_review.py, including the two-line security fix this PR carries.Same wall as #15950's
_execute_claimed, which is the second instance and theevidence behind #16191.
The file also sat at 972 lines against a recorded ceiling of 972, zero
headroom. Splitting a function within the file would have made it longer, and a
ratchet may shrink but never grow. So the two halves leave the file entirely
rather than moving inside it — that satisfies the length guard and the size
ratchet with one change.
What Changed
Security (
#16179, the last of seven unscrubbed git call sites).get_git_diffnow goes throughautobot_shared.git_probe.start_gitinstead of abare
asyncio.create_subprocess_exec, so the git environment is scrubbed —GIT_DIRoutranks both-Candcwd, so an inherited value silently redirectsthis diff at another repository.
strict=Trueis the default and is correct here:this is a
git diffon local refs, not a transport call.The argv is built without
"git"in it, becausestart_gitprepends it. Alist carrying
"git"would rungit git diffthe first time a later edit passedthe whole list.
analytics_code_review_diff.py(new) receives two blocks verbatim:collect_file_comments— the per-file analysis looppersist_review— the Redis result/history writeCeiling lowered 972 → 929 in both
scripts/python_file_size_known_large.pyand
repo_tests/python_file_size_ratchet_baseline.py, as the audit instructed:"an unlowered ceiling re-licenses the lines just cut."
No function in the file now exceeds 65 lines.
Verification
Given what the equivalent split shipped in #15950 — three control-flow defects,
all four linters green on every one — this one was checked differently:
captured before the cut: 21/21 and 28/28 statements accounted for, 0 missing.
return type against every path that can reach its end. 0 findings. That auditor
was itself validated against a reproduction of Enforce work claims: task executor and base agent acquire declared scopes #15950's two review findings and
catches both; its first version caught neither, because a substring test for
"None"skippedstr | Noneandtuple[str, dict | None]— the same blindspot that let the original defect past mypy.
landed at module level rather than inside
persist_review, leaving thefunction an empty shell. Found by
aststructure inspection, not by a linter.By exit code, not piped output:
flake80,isort --check-only0 with CI's exactsettings,
check_python_file_size --audit-ceilings0,check_undefined_names --audit0.Model Used
Claude Opus 5 (1M context).
Single-issue rationale
Two issues in one PR, which is the batching default: the extraction exists only to
unblock the file, and the security fix is what needed unblocking. Splitting them
would mean landing a refactor with no reason attached, then a two-line fix behind
a second full CI run.
Closes #16186
Completes #16179