-
Notifications
You must be signed in to change notification settings - Fork 931
Updated osquery perf for #45550 #48935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -547,8 +547,15 @@ type agent struct { | |
| // cache of this host's per-host certificates (the certs unique to this host, excluding the shared certs every host | ||
| // reports). Note that this requires a mutex even though only used in a.processQuery, that's because both the runLoop | ||
| // and the live query goroutines may call DistributedWrite (which calls processQuery). | ||
| certificatesMutex sync.RWMutex | ||
| hostCertSpecs []simulatedCert | ||
| certificatesMutex sync.RWMutex | ||
| hostCertSpecs []simulatedCert | ||
| // scepCertSpecs holds the certs issued to this host during Windows MDM SCEP exchanges, keyed by the SCEP CSP | ||
| // unique ID so a re-issued cert replaces its predecessor. | ||
| scepCertSpecs map[string]simulatedCert | ||
| // withholdSCEPCert marks ~5% of hosts that never report their issued SCEP certs, exercising the server's SCEP | ||
| // verification backstop (test-only failure). | ||
| withholdSCEPCert bool | ||
|
|
||
| commonSoftwareNameSuffix string | ||
|
|
||
| entraIDDeviceID string | ||
|
|
@@ -727,6 +734,8 @@ func newAgent( | |
| cachedLastOpenedAt: make(map[string]*time.Time), | ||
| commonSoftwareNameSuffix: commonSoftwareNameSuffix, | ||
| mdmProfileFailureProb: mdmProfileFailureProb, | ||
| // Every 20th host (5%) withholds its issued SCEP certs to exercise the server's verification backstop (test-only failure). | ||
| withholdSCEPCert: agentIndex%20 == 0, | ||
|
Comment on lines
+737
to
+738
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect the relevant file and nearby context.
git ls-files cmd/osquery-perf/agent.go
wc -l cmd/osquery-perf/agent.go
sed -n '680,780p' cmd/osquery-perf/agent.go
# Find definitions and call sites for the relevant identifiers.
rg -n "withholdSCEPCert|agentIndex|hostIndexOffset|newAgent\(" cmd/osquery-perf/agent.go cmd/osquery-perf -SRepository: fleetdm/fleet Length of output: 8286 🏁 Script executed: #!/bin/bash
set -euo pipefail
git ls-files cmd/osquery-perf/agent.go
wc -l cmd/osquery-perf/agent.go
sed -n '680,780p' cmd/osquery-perf/agent.go
rg -n "withholdSCEPCert|agentIndex|hostIndexOffset|newAgent\(" cmd/osquery-perf/agent.go cmd/osquery-perf -SRepository: fleetdm/fleet Length of output: 8286 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Show the newAgent signature and the call sites that pass hostIndexOffset / agentIndex.
rg -n "func newAgent|newAgent\(" cmd/osquery-perf/agent.go cmd/osquery-perf -S -A 4 -B 4
# Show any calculations that define agentIndex or hostIndexOffset in the same file.
rg -n "hostIndexOffset|agentIndex" cmd/osquery-perf/agent.go -S -A 3 -B 3Repository: fleetdm/fleet Length of output: 7544 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Read only the relevant slice with line numbers.
nl -ba cmd/osquery-perf/agent.go | sed -n '700,760p'
# Show the declaration/call site context for hostIndexOffset and agentIndex.
rg -n "hostIndexOffset|agentIndex|withholdSCEPCert" cmd/osquery-perf/agent.go -n -A 6 -B 6Repository: fleetdm/fleet Length of output: 191 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path("cmd/osquery-perf/agent.go")
lines = p.read_text().splitlines()
for start, end in [(2168,2208),(3884,3924),(728,742)]:
print(f"\n--- {start}-{end} ---")
for i in range(start, end+1):
if i <= len(lines):
print(f"{i:4d}: {lines[i-1]}")
PYRepository: fleetdm/fleet Length of output: 4188 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path("cmd/osquery-perf/agent.go")
lines = p.read_text().splitlines()
for start, end in [(3648, 3672), (3880, 3935), (2188, 2210)]:
print(f"\n--- {start}-{end} ---")
for i in range(start, end + 1):
if i <= len(lines):
print(f"{i:4d}: {lines[i-1]}")
PYRepository: fleetdm/fleet Length of output: 5219 Base the withholding cohort on the global host index. 🤖 Prompt for AI Agents |
||
|
|
||
| entraIDDeviceID: uuid.NewString(), | ||
| entraIDUserPrincipalName: fmt.Sprintf("fake-%s@example.com", randomString(5)), | ||
|
|
@@ -1624,6 +1633,16 @@ func (a *agent) doWindowsMDMCheckIn(onDemand bool) (newPollInterval time.Duratio | |
| continue | ||
| } | ||
| a.stats.IncrementMDMSCEPSuccess() | ||
| if res.Cert == nil { | ||
| continue | ||
| } | ||
| // Report the issued cert via the certificates detail query so the server observes the | ||
| // fleet-<profileUUID> renewal-ID marker and marks the SCEP profile verified. The withheld ~5% never | ||
| // report theirs, so the server's verification backstop fails those profiles. | ||
| if a.withholdSCEPCert { | ||
| continue | ||
| } | ||
| a.storeSCEPCertSpec(res.UniqueID, res.Cert) | ||
| } | ||
| }() | ||
| } else { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like a stylistic thing, but the pattern I have seen with other maps is to use
maketo initialize them innewAgentin