Skip to content

53 analyzer expand security coverage enforce global strict test runner stabilize expectation matching#54

Open
SizzleUnrlsd wants to merge 143 commits intomainfrom
53-analyzer-expand-security-coverage-enforce-global-strict-test-runner-stabilize-expectation-matching
Open

53 analyzer expand security coverage enforce global strict test runner stabilize expectation matching#54
SizzleUnrlsd wants to merge 143 commits intomainfrom
53-analyzer-expand-security-coverage-enforce-global-strict-test-runner-stabilize-expectation-matching

Conversation

@SizzleUnrlsd
Copy link
Contributor

Summary

This PR consolidates a broad analyzer + test infrastructure effort:

  • expanded security analysis coverage,
  • hardened run_test.py with global strict validation,
  • fixed expectation matching regressions (both too brittle and too permissive cases),
  • added/fixed/reorganized security fixtures.

Main changes

1) Analyzer / pipeline

  • Added and integrated multiple security analyses (including null deref, integer overflow, TOCTOU, command injection, OOB read, type confusion).
  • Updated core components:
    • src/analyzer/AnalysisPipeline.cpp
    • src/analyzer/DiagnosticEmitter.cpp
    • src/app/AnalyzerApp.cpp
    • src/analysis/*
    • include/analysis/*
  • Updated models:
    • models/resource-lifetime/generic.txt
    • models/buffer-overflow/generic.txt

2) Test runner (run_test.py)

  • Enabled strict warning/error count as a global policy for fixtures.
  • Enforced strict validation even when expectations are partial.
  • Improved matching for combined diagnostics within the same location block.
  • Fixed location tolerance behavior:
    • resilient to realistic line drift,
    • rejects obviously stale/far-off line anchors.
  • Relaxed brittle inter-TU checks that depended on exact line-number strings.

3) Test corpus

  • Backfilled missing expectations in many fixtures.
  • Added advanced regression cases (nested control flow, inter-TU, tricky paths).
  • Reorganized security fixtures into:
    • test/security/<vulnerability-category>/...
  • Kept legacy compatibility through test/files shim documentation/Makefile.

Validation

  • Command:
    • python3 run_test.py --jobs=8
  • Result:
    • 821/821 passed

Behavior changes

  • Strict count is now a central quality gate:
    • tests fail when warning/error comments do not match analyzer output count.
  • Stale line anchors are no longer silently accepted by over-tolerant matching.

Exclusions for this PR

Please explicitly exclude:

  • tmp/
  • .cache/
  • local artifacts (.DS_Store, __pycache__, local analysis outputs)

Checklist

  • Analyzer integrated and buildable
  • Strict runner behavior stabilized
  • Regression suite green
  • Security corpus reorganized
  • Local artifacts excluded

llvm::SmallPtrSetImpl<const llvm::Value*>& visited,
unsigned depth)
{
if (!value || depth > 32)

Check notice

Code scanning / coretrace-stack-analyzer

None Note

[ !Info! ] recursive or mutually recursive function detected
static bool hasKnownNonNegativeRange(const llvm::Value* value,
const std::map<const llvm::Value*, IntRange>& ranges)
{
if (!value)

Check notice

Code scanning / coretrace-stack-analyzer

None Note

[ !Info! ] recursive or mutually recursive function detected
const llvm::Value* value, const std::map<const llvm::Value*, IntRange>& ranges,
llvm::SmallPtrSetImpl<const llvm::Value*>& visited, unsigned depth)
{
if (!value || depth > 32)

Check notice

Code scanning / coretrace-stack-analyzer

None Note

[ !Info! ] recursive or mutually recursive function detected
resolveConstIntRecursive(const llvm::Value* value,
llvm::SmallPtrSetImpl<const llvm::Value*>& visited, unsigned depth)
{
if (!value || depth > 32)

Check notice

Code scanning / coretrace-stack-analyzer

None Note

[ !Info! ] recursive or mutually recursive function detected
llvm::SmallPtrSetImpl<const llvm::Value*>& visited,
unsigned depth)
{
if (!value || depth > 32)

Check notice

Code scanning / coretrace-stack-analyzer

None Note

[ !Info! ] recursive or mutually recursive function detected
llvm::SmallPtrSetImpl<const llvm::Value*>& visited,
unsigned depth)
{
if (!value || depth > 32)

Check notice

Code scanning / coretrace-stack-analyzer

None Note

[ !Info! ] recursive or mutually recursive function detected
static std::optional<IntRange>
lookupRange(const llvm::Value* value, const std::map<const llvm::Value*, IntRange>& ranges)
{
if (!value)

Check notice

Code scanning / coretrace-stack-analyzer

None Note

[ !Info! ] recursive or mutually recursive function detected
llvm::SmallPtrSet<const llvm::Value*, 32>& visited,
bool& sawReleaseUse, unsigned depth = 0)
{
if (!value || depth > 10)

Check notice

Code scanning / coretrace-stack-analyzer

None Note

[ !Info! ] recursive or mutually recursive function detected
static bool isArrayBackedType(const llvm::Type* type)
{
using namespace llvm;
if (!type)

Check notice

Code scanning / coretrace-stack-analyzer

None Note

[ !Info! ] recursive or mutually recursive function detected
std::unordered_set<const llvm::Type*>& visiting,
unsigned depth = 0)
{
if (!haystack || !needle || depth > 24)

Check notice

Code scanning / coretrace-stack-analyzer

None Note

[ !Info! ] recursive or mutually recursive function detected
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.

[Analyzer] Expand security coverage + enforce global strict test runner + stabilize expectation matching

1 participant