Skip to content

Conversation

@shivasurya
Copy link
Owner

@shivasurya shivasurya commented Nov 20, 2025

This enhancement extends the DSL intermediate representation to support keyword argument constraints in function call matching. The CallMatcherIR structure now includes a KeywordArgs map that allows rules to specify expected values for named parameters. This provides the foundation for more precise security rule definitions that can validate specific argument values rather than just function names.

This PR implements the foundation for argument value checking by:

1. Extended CallMatcherIR with ArgumentConstraint and KeywordArgs
   - Added ArgumentConstraint struct to represent argument value constraints
   - Added KeywordArgs field to CallMatcherIR (with omitempty for backward compat)
   - Supports single values and lists of values (OR logic)
   - Includes wildcard flag for pattern matching

2. Implemented parseKeywordArguments() function
   - Extracts keyword arguments from CallSite.Arguments
   - Handles "key=value" format parsing
   - Trims whitespace from keys and values
   - Supports complex values (nested objects, URLs with =)
   - O(N) performance where N = number of arguments

3. Added comprehensive unit tests (10 tests, 100% coverage)
   - Empty arguments
   - Positional-only arguments
   - Single keyword argument
   - Multiple keyword arguments
   - Mixed positional and keyword
   - Whitespace handling
   - Complex values
   - Edge cases
   - ArgumentConstraint struct usage
   - Backward compatibility

Test Results:
- All 10 new tests pass ✓
- 100% coverage on parseKeywordArguments() ✓
- 89.1% overall coverage on dsl package ✓
- No regression in existing tests ✓
- Build successful ✓

This change is backward compatible - existing IR without KeywordArgs
continues to work unchanged.

Implements: PR #1 from argument-value-checking tech spec
Related: Phase 1 - High Priority (200 rules requiring arg checking)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@safedep
Copy link

safedep bot commented Nov 20, 2025

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

This report is generated by SafeDep Github App

@codecov
Copy link

codecov bot commented Nov 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.73%. Comparing base (8067039) to head (e79f3a3).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #384      +/-   ##
==========================================
+ Coverage   78.70%   78.73%   +0.03%     
==========================================
  Files          70       70              
  Lines        6923     6933      +10     
==========================================
+ Hits         5449     5459      +10     
  Misses       1237     1237              
  Partials      237      237              

☔ 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.

@shivasurya shivasurya self-assigned this Nov 20, 2025
@shivasurya shivasurya added enhancement New feature or request go Pull requests that update go code labels Nov 20, 2025
- Add missing period in godot comment
- Change JSON tag from keyword_args to keywordArgs (camelCase)

Lint now passes: 0 issues
Copy link
Owner Author

shivasurya commented Nov 21, 2025

Merge activity

  • Nov 21, 1:29 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Nov 21, 1:29 AM UTC: @shivasurya merged this pull request with Graphite.

@shivasurya shivasurya merged commit 323b8e9 into main Nov 21, 2025
5 checks passed
@shivasurya shivasurya deleted the shiva/pr-01-dsl-ir-extension-keyword-args branch November 21, 2025 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants