Skip to content

fix(OSQUERY-010): 2 review findings in apt_sources.cpp - #45

Draft
flamingo[bot] wants to merge 1 commit into
masterfrom
ai-fix/osquery-010-efaf7fb4-01e7aadc
Draft

fix(OSQUERY-010): 2 review findings in apt_sources.cpp#45
flamingo[bot] wants to merge 1 commit into
masterfrom
ai-fix/osquery-010-efaf7fb4-01e7aadc

Conversation

@flamingo

@flamingo flamingo Bot commented Aug 24, 2026

Copy link
Copy Markdown

Closes 2 review findings in osquery/tables/system/linux/apt_sources.cpp.

Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.

# Fix confidence Finding Location
1 🟢 95 high apt_sources.cpp back()-on-empty-string risk when parsing base_uri trailing slashes osquery/tables/system/linux/apt_sources.cpp:89
2 🟢 95 high Same unchecked .back() pattern repeated in parseDeb822Block URI trimming osquery/tables/system/linux/apt_sources.cpp:253

What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.


Run: https://product-hub.flamingo.so/admin/code-review
Run id: 01e7aadc-0204-47ef-b373-fc5dbadf3ab5

Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.

@flamingo flamingo Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 What this fix changed, finding by finding

2 finding(s) fixed in this draft — 2 explained inline on the diff.

while (apt_source.base_uri.back() == '/') {
while (!apt_source.base_uri.empty() && apt_source.base_uri.back() == '/') {
apt_source.base_uri.pop_back();
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 apt_sources.cpp back()-on-empty-string risk when parsing base_uri trailing slashes

In parseAptSourceLine, the trailing-slash trimming loop on apt_source.base_uri now checks !apt_source.base_uri.empty() before calling .back(), preventing undefined behavior when the URI is all slashes.

🤖 Prompt for AI agents
In osquery/tables/system/linux/apt_sources.cpp around line 89, review and complete this code-review fix: apt_sources.cpp back()-on-empty-string risk when parsing base_uri trailing slashes.
What the draft fix changed: In `parseAptSourceLine`, the trailing-slash trimming loop on `apt_source.base_uri` now checks `!apt_source.base_uri.empty()` before calling `.back()`, preventing undefined behavior when the URI is all slashes.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer

Comment on lines 264 to 270
continue;
}
// Cannot have trailing slashes
while (uri.back() == '/') {
while (!uri.empty() && uri.back() == '/') {
uri.pop_back();
}
uris.push_back(uri);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 Same unchecked .back() pattern repeated in parseDeb822Block URI trimming

In parseDeb822Block, the trailing-slash trimming loop on uri (inside the key == "uris" branch) now checks !uri.empty() before calling .back(), preventing undefined behavior for malformed all-slash URIs from DEB822 sources.

🤖 Prompt for AI agents
In osquery/tables/system/linux/apt_sources.cpp around line 253, review and complete this code-review fix: Same unchecked .back() pattern repeated in parseDeb822Block URI trimming.
What the draft fix changed: In `parseDeb822Block`, the trailing-slash trimming loop on `uri` (inside the `key == "uris"` branch) now checks `!uri.empty()` before calling `.back()`, preventing undefined behavior for malformed all-slash URIs from DEB822 sources.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer

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.

0 participants