Skip to content

Scan android hosts for vulnerabilities - #49319

Merged
ksykulev merged 5 commits into
35075-software-os-show-android-versions-and-vulnerabilitiesfrom
andriod-scanning
Jul 15, 2026
Merged

Scan android hosts for vulnerabilities#49319
ksykulev merged 5 commits into
35075-software-os-show-android-versions-and-vulnerabilitiesfrom
andriod-scanning

Conversation

@ksykulev

@ksykulev ksykulev commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Related issue: Resolves #47336

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

@ksykulev
ksykulev requested a review from a team as a code owner July 15, 2026 02:32
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.64126% with 90 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.98%. Comparing base (883efbf) to head (21aad1d).
⚠️ Report is 1 commits behind head on 35075-software-os-show-android-versions-and-vulnerabilities.

Files with missing lines Patch % Lines
cmd/fleet/cron.go 0.00% 36 Missing and 1 partial ⚠️
server/vulnerabilities/osv/sync.go 58.22% 28 Missing and 5 partials ⚠️
server/vulnerabilities/android/analyzer.go 81.13% 11 Missing and 9 partials ⚠️
Additional details and impacted files
@@                                       Coverage Diff                                       @@
##           35075-software-os-show-android-versions-and-vulnerabilities   #49319      +/-   ##
===============================================================================================
+ Coverage                                                        67.97%   67.98%   +0.01%     
===============================================================================================
  Files                                                             3801     3806       +5     
  Lines                                                           239965   240886     +921     
  Branches                                                         12693    12693              
===============================================================================================
+ Hits                                                            163123   163776     +653     
- Misses                                                           62058    62233     +175     
- Partials                                                         14784    14877      +93     
Flag Coverage Δ
backend 69.57% <59.64%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds Android OS-version vulnerability scanning by downloading Android OSV artifacts and matching them against operating_systems rows (major + SPL) to write CVEs into operating_system_vulnerabilities, wired into the vulnerability cron.

Changes:

  • Extend OSV syncing to recognize and download osv-android-* artifacts (including inventory-driven refresh).
  • Add an Android analyzer that loads the gzipped artifact, matches SPL vs fixed SPL, and upserts OS vulnerabilities (delta insert/delete).
  • Wire Android analysis into the vuln cron and add unit tests for the new analyzer and updated OSV syncing helpers.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
server/vulnerabilities/osv/sync.go Adds Android OSV artifact prefix support and Android-specific refresh + cleanup logic.
server/vulnerabilities/osv/sync_test.go Updates tests for expanded versionsFromRelease return values.
server/vulnerabilities/android/analyzer.go Implements Android OSV artifact loading + SPL-based matching and OS vuln upsert logic.
server/vulnerabilities/android/analyzer_test.go Adds unit tests for parsing + matching behavior and delta deletion behavior.
server/fleet/vulnerabilities.go Introduces AndroidOSVSource as a new VulnerabilitySource.
cmd/fleet/cron.go Adds an Android OSV phase to the vuln scan cron (sync + analyze).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/vulnerabilities/osv/sync.go
Comment thread server/vulnerabilities/android/analyzer.go
Comment thread server/vulnerabilities/osv/sync_test.go
Comment thread cmd/fleet/cron.go Outdated
logger.InfoContext(ctx, "phase completed", "phase", "windows_msrc", "elapsed", time.Since(phaseStart))

phaseStart = time.Now()
checkAndroidVulnerabilities(ctx, ds, logger, vulnPath, config, vulnAutomationEnabled != "")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be gated by config.OSVForVulnerabilities ?


// LatestArtifactDate returns the date encoded in the latest Android artifact
// filename for the given version, or zero time if none found.
func LatestArtifactDate(majorVersion, vulnPath string) time.Time {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Dead code?

Comment thread cmd/fleet/cron.go Outdated
analyzeCtx, analyzeSpan := tracer.Start(ctx, "vuln.android.analyze")
for _, o := range oses {
start := time.Now()
r, err := androidvuln.Analyze(analyzeCtx, ds, o, vulnPath, collectVulns, logger)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will call loadArtifact for each o, even though the artifact is only a function of the "major version", right?

Maybe something that can be optimized by keeping a cache of loaded artifacts and then providing that to Analyze.

@juan-fdz-hawa

Copy link
Copy Markdown
Contributor

There are some gaps here in testing:

  • removeOldAndroidOSVArtifacts has no tests.
  • getNeededAndroidVersions
  • loadArtifact latest-selection untested
  • Corrupt/empty-artifact safety is untested

func TestResolvedVersion(t *testing.T) {
got := resolvedVersion("16", "2026-06-01")
require.NotNil(t, got)
assert.Equal(t, "16 (2026-06-01)", *got)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: lets use require here for consistency

SELECT id, name, version, arch, kernel_version, platform, display_version, installation_type, os_version_id
FROM operating_systems
WHERE platform = ?
ORDER BY version

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is to support not loading all of the android artifacts into cache, but rather one version at at time.

@ksykulev
ksykulev merged commit 76b4faf into 35075-software-os-show-android-versions-and-vulnerabilities Jul 15, 2026
35 checks passed
@ksykulev
ksykulev deleted the andriod-scanning branch July 15, 2026 19:35
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.

3 participants