feat: add ProbeIMAExecMeasurementActive#59
Merged
Conversation
Rejects trailing junk (e.g. '42abc') that fmt.Sscanf would silently accept. The kernel file should never contain such content, but this is stricter parser hygiene for a public helper's internals. Co-authored-by: Ona <no-reply@ona.com>
Checks whether an IMA measurement rule covering exec (e.g., func=BPRM_CHECK) is active by creating a fresh temporary executable (new inode), running it, and checking for a measurement count increase. No count > 1 shortcut: returns Supported=true only when the controlled exec stimulus increments the count. A fresh inode avoids false negatives from IMA's per-inode measurement cache. Co-authored-by: Ona <no-reply@ona.com>
Tests that execFreshTempBinary creates, executes, and cleans up the temp binary. Adds a trailing-junk subtest for readMeasurementCountFrom to verify the strconv.Atoi strictness. Co-authored-by: Ona <no-reply@ona.com>
Co-authored-by: Ona <no-reply@ona.com>
Materialize the temp binary before reading the baseline count so the counted window contains only the exec stimulus. Splits execFreshTempBinary into createFreshTempBinary (returns path + cleanup) and execTempBinary (takes path). Avoids false positives from FILE_CHECK rules measuring the source read or temp-file write during setup. Co-authored-by: Ona <no-reply@ona.com>
Tests createFreshTempBinary (executable path, cleanup removes dir), execTempBinary (success, nonexistent path error). Co-authored-by: Ona <no-reply@ona.com>
ProbeIMAExecMeasurementActive
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.
Added
ProbeIMAExecMeasurementActive() ProbeResult— checks whether an IMA measurement rule covering exec (e.g.,func=BPRM_CHECK) is active by creating a fresh temporary executable (new inode), running it, and checking for a measurement count increase.Semantic contract
Supported=trueonly when the controlled exec stimulus increments the IMA measurement countProbeIMAAnyMeasurementActive)/bin/truein a temp dir) to avoid false negatives from IMA's per-inode measurement cacheFILE_CHECKrules measuring the source read or temp-file writeSupported=falsewithErrorsetFeature/Check/SystemFeaturesyetAlso in this PR
readMeasurementCountFromswitched fromfmt.Sscanftostrconv.Atoi— rejects trailing junk like"42abc"thatSscanfwould silently acceptcreateFreshTempBinary(executable path, cleanup),execTempBinary(success, nonexistent path error), and a trailing-junk subtest forreadMeasurementCountFromSeries
This is PR 2 of 3 after #57:
ReadIMARuntimeMeasurementsCount✅ProbeIMAExecMeasurementActiveProbeIMAFileCheckMeasurementActive— fresh temp file, same pattern