Skip to content

Fix Jetbrains versions - Take 2#40928

Merged
mostlikelee merged 5 commits intomainfrom
26405-jetbrains-fix
Mar 6, 2026
Merged

Fix Jetbrains versions - Take 2#40928
mostlikelee merged 5 commits intomainfrom
26405-jetbrains-fix

Conversation

@mostlikelee
Copy link
Contributor

@mostlikelee mostlikelee commented Mar 4, 2026

Related issue: Resolves #26405

This includes a revert of the original PR due to running into denylisting with the additional detail query. And adds a new software mutator that transforms the version string instead. Some refactoring done to customAppSanitizer so it can be used for any source type.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.

  • Added/updated automated tests

  • QA'd all new/changed functionality manually

For unreleased bug fixes in a release candidate, one of:

  • Confirmed that the fix is not expected to adversely impact load test results

Summary by CodeRabbit

  • Bug Fixes

    • Improved JetBrains version detection on Windows by extracting standard marketing versions from product names (Toolbox unaffected).
    • Fixed RPM kernel reporting to produce correct combined version strings and clear release where appropriate.
  • Documentation

    • Removed the Windows JetBrains override from host vitals docs to align with updated discovery behavior.
  • Tests

    • Added tests covering JetBrains and RPM kernel sanitization scenarios.

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.32%. Comparing base (f6da797) to head (b102013).
⚠️ Report is 80 commits behind head on main.

Files with missing lines Patch % Lines
server/service/osquery_utils/queries.go 85.71% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #40928      +/-   ##
==========================================
+ Coverage   66.31%   66.32%   +0.01%     
==========================================
  Files        2469     2469              
  Lines      197844   197910      +66     
  Branches     8675     8634      -41     
==========================================
+ Hits       131205   131270      +65     
+ Misses      54768    54762       -6     
- Partials    11871    11878       +7     
Flag Coverage Δ
backend 68.11% <85.71%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mostlikelee
Copy link
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

Walkthrough

Removed the Windows-specific software_windows_jetbrains override and its documentation entry. Deleted the JetBrains Windows discovery whitelist entry in tests. Introduced a JetBrains name/version sanitizer that extracts year-based build versions from product names (excluding Toolbox), and an RPM kernel sanitizer that joins kernel version and release then clears Release. Renamed customAppSanitizers to customSanitizers and updated MutateSoftwareOnIngestion to apply sanitizers with nil guards and panic protection. Updated tests to cover JetBrains and RPM kernel sanitization and adjusted expected detail queries accordingly.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "Fix Jetbrains versions - Take 2" is vague and generic, using non-descriptive phrasing that doesn't clearly convey what changed or why the PR is needed. Use a more specific title that describes the actual change, such as "Replace JetBrains detail query with name-based version sanitizer" or "Fix JetBrains Windows version detection via product name parsing."
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description covers the key aspects: it references the linked issue #26405, explains the approach (reverting and adding a new software mutator), mentions the refactoring done, and confirms the relevant checklist items are checked.
Linked Issues check ✅ Passed The changes address the core requirement from #26405: translating JetBrains Windows triple-digit versions to year-based versions. The implementation adds a jetbrainsNameVersion sanitizer that extracts version strings from JetBrains product names and properly handles exclusions (Toolbox), meeting the issue's objectives.
Out of Scope Changes check ✅ Passed All changes are scoped to the JetBrains Windows version issue: reverting the detail query approach, adding version mutation logic, refactoring sanitizers, and updating tests. The RPM kernel sanitizer is a necessary supporting change for the refactoring. No unrelated changes detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 26405-jetbrains-fix

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@server/service/osquery_utils/queries.go`:
- Around line 2234-2237: The Toolbox exclusion is currently case-sensitive
(`!strings.Contains(s.Name, "Toolbox")`), so change it to a case-insensitive
check by lowercasing s.Name before matching (e.g., replace that condition with
`!strings.Contains(strings.ToLower(s.Name), "toolbox")`) in the same expression
that also checks s.Source, s.Vendor and
jetbrainsBuildFormat.MatchString(s.Version).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 97167797-a770-4092-9736-97ec6842815c

📥 Commits

Reviewing files that changed from the base of the PR and between a553baa and ceb18fa.

📒 Files selected for processing (5)
  • changes/26405-jetbrains
  • docs/Contributing/product-groups/orchestration/understanding-host-vitals.md
  • server/service/osquery_test.go
  • server/service/osquery_utils/queries.go
  • server/service/osquery_utils/queries_test.go
💤 Files with no reviewable changes (2)
  • docs/Contributing/product-groups/orchestration/understanding-host-vitals.md
  • server/service/osquery_test.go

Comment on lines +2234 to +2237
return s.Source == "programs" &&
strings.Contains(strings.ToLower(s.Vendor), "jetbrains") &&
!strings.Contains(s.Name, "Toolbox") &&
jetbrainsBuildFormat.MatchString(s.Version)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Make Toolbox exclusion case-insensitive.

Line 2236 is case-sensitive, so a value like jetbrains toolbox can be incorrectly transformed.

🔧 Proposed fix
-					!strings.Contains(s.Name, "Toolbox") &&
+					!strings.Contains(strings.ToLower(s.Name), "toolbox") &&
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return s.Source == "programs" &&
strings.Contains(strings.ToLower(s.Vendor), "jetbrains") &&
!strings.Contains(s.Name, "Toolbox") &&
jetbrainsBuildFormat.MatchString(s.Version)
return s.Source == "programs" &&
strings.Contains(strings.ToLower(s.Vendor), "jetbrains") &&
!strings.Contains(strings.ToLower(s.Name), "toolbox") &&
jetbrainsBuildFormat.MatchString(s.Version)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/service/osquery_utils/queries.go` around lines 2234 - 2237, The
Toolbox exclusion is currently case-sensitive (`!strings.Contains(s.Name,
"Toolbox")`), so change it to a case-insensitive check by lowercasing s.Name
before matching (e.g., replace that condition with
`!strings.Contains(strings.ToLower(s.Name), "toolbox")`) in the same expression
that also checks s.Source, s.Vendor and
jetbrainsBuildFormat.MatchString(s.Version).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not concerned about this

@mostlikelee
Copy link
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

✅ Actions performed

Full review triggered.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
server/service/osquery_utils/queries.go (1)

2232-2235: ⚠️ Potential issue | 🟡 Minor

Make Toolbox exclusion case-insensitive.

At Line 2234, Toolbox exclusion is still case-sensitive, so names like jetbrains toolbox can be incorrectly transformed.

🔧 Suggested patch
-					!strings.Contains(s.Name, "Toolbox") &&
+					!strings.Contains(strings.ToLower(s.Name), "toolbox") &&
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/service/osquery_utils/queries.go` around lines 2232 - 2235, The
Toolbox exclusion is currently case-sensitive; update the predicate that returns
for JetBrains programs to perform a case-insensitive check on s.Name by
replacing the !strings.Contains(s.Name, "Toolbox") check with a lowercase
comparison, e.g. !strings.Contains(strings.ToLower(s.Name), "toolbox"), keeping
the other conditions (s.Source, strings.ToLower(s.Vendor), and
jetbrainsNameVersion.MatchString(s.Name)) unchanged.
🧹 Nitpick comments (1)
server/service/osquery_utils/queries_test.go (1)

126-126: Update stale test comment naming.

Line 126 still says customAppSanitizers, but the implementation now uses customSanitizers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/service/osquery_utils/queries_test.go` at line 126, Update the stale
inline test comment that references "customAppSanitizers" to the current name
"customSanitizers" in the queries_test.go test (the comment above the TNMS test
case); locate the comment near the TNMS test block and replace the old
identifier so the comment matches the implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@server/service/osquery_utils/queries.go`:
- Around line 2232-2235: The Toolbox exclusion is currently case-sensitive;
update the predicate that returns for JetBrains programs to perform a
case-insensitive check on s.Name by replacing the !strings.Contains(s.Name,
"Toolbox") check with a lowercase comparison, e.g.
!strings.Contains(strings.ToLower(s.Name), "toolbox"), keeping the other
conditions (s.Source, strings.ToLower(s.Vendor), and
jetbrainsNameVersion.MatchString(s.Name)) unchanged.

---

Nitpick comments:
In `@server/service/osquery_utils/queries_test.go`:
- Line 126: Update the stale inline test comment that references
"customAppSanitizers" to the current name "customSanitizers" in the
queries_test.go test (the comment above the TNMS test case); locate the comment
near the TNMS test block and replace the old identifier so the comment matches
the implementation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0a6bf797-731c-4182-a2d9-348a032ea277

📥 Commits

Reviewing files that changed from the base of the PR and between a553baa and 6007042.

📒 Files selected for processing (5)
  • changes/26405-jetbrains
  • docs/Contributing/product-groups/orchestration/understanding-host-vitals.md
  • server/service/osquery_test.go
  • server/service/osquery_utils/queries.go
  • server/service/osquery_utils/queries_test.go
💤 Files with no reviewable changes (2)
  • server/service/osquery_test.go
  • docs/Contributing/product-groups/orchestration/understanding-host-vitals.md

@mostlikelee mostlikelee changed the title 26405 jetbrains fix Fix Jetbrains versions - Take 2 Mar 4, 2026
// Software queries expect specific columns to be present. Reference the
// software_{macos|windows|linux} queries for the expected columns.
var SoftwareOverrideQueries = map[string]DetailQuery{
// windows_jetbrains uses the version contained in the product-info.json file as exe installers
Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverting the initial approach of adding a new detail query because the query was getting denylisted

Copy link
Contributor

Choose a reason for hiding this comment

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

🧼

@mostlikelee mostlikelee marked this pull request as ready for review March 4, 2026 19:01
@mostlikelee mostlikelee requested review from a team, sgress454 and sharon-fdm as code owners March 4, 2026 19:01
@mostlikelee
Copy link
Contributor Author

mysql tests are failing because of https://fleetdm.slack.com/archives/C019WG4GH0A/p1772649082281189

},
{
// JetBrains products on Windows report build numbers (e.g., "253.31033.139")
// instead of marketing versions. This sanitizer extracts the version from
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

return s.Source == "programs" &&
strings.Contains(strings.ToLower(s.Vendor), "jetbrains") &&
!strings.Contains(s.Name, "Toolbox") &&
jetbrainsNameVersion.MatchString(s.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

👌

// all of our current on-ingest mutations use this table,
// so might as well let other stuff go faster and save some redundant checks inside the matchers
if s != nil && s.Source == "apps" {
if s == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

DSA 101 🙂

jetbrainsNameVersion.MatchString(s.Name)
},
mutate: func(s *fleet.Software, logger *slog.Logger) {
if matches := jetbrainsNameVersion.FindStringSubmatch(s.Name); len(matches) == 2 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a clearer way to say "find a match and return it stripped of whitespace", or is this pretty
cannonical? Took me a minute to grok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is pretty canonical when using regex, but agree the regex can be hard to grok. hesitant to parse with the strings package as we have set a pattern of using regex here.

@jacobshandling jacobshandling self-requested a review March 4, 2026 22:00
@jacobshandling
Copy link
Contributor

Just the change file please, all else LGTM, will approve once (if?!) CI test queue gets sorted

Co-authored-by: jacobshandling <61553566+jacobshandling@users.noreply.github.com>
Copy link
Collaborator

@sharon-fdm sharon-fdm left a comment

Choose a reason for hiding this comment

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

I only reviewed docs/Contributing/product-groups/orchestration/understanding-host-vitals.md

Relying on previous approvals for the rest.

@mostlikelee mostlikelee merged commit 3681306 into main Mar 6, 2026
52 of 53 checks passed
@mostlikelee mostlikelee deleted the 26405-jetbrains-fix branch March 6, 2026 19:30
mostlikelee added a commit that referenced this pull request Mar 6, 2026
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.

🪲JetBrains Windows products installed outside JetBrains Toolbox don't show year-based versions

3 participants