Skip to content

example(policy): New json-field-validator policy example#2328

Merged
migmartri merged 1 commit into
chainloop-dev:mainfrom
danlishka:PFM-3462
Aug 11, 2025
Merged

example(policy): New json-field-validator policy example#2328
migmartri merged 1 commit into
chainloop-dev:mainfrom
danlishka:PFM-3462

Conversation

@danlishka

Copy link
Copy Markdown
Member

Summary

Adds a comprehensive JSON field validation policy example with shared testing utilities and improved policy structure.

Changes

New Policy Example

  • json-field-validator/: Complete policy example for validating JSON fields
  • Generic field validation with dot notation support (application.name, security.enabled)
  • Configurable validation types (exact values, regex patterns)
  • Works with EVIDENCE material type for JSON files

Enhanced Testing Framework

  • Shared _testutils.sh: Configurable test utilities supporting multiple material types
  • Proper exit codes (0 for pass, 1 for fail)
  • Skipped/ignored policy detection
  • Custom material type support (--kind parameter)

Additional Improvements

  • sbom-freshness/: Restructured SBOM policy following new template

Policy Features

  • Field Validation: required_field=application.name expected_value=web-service
  • Pattern Matching: required_field=version field_pattern="^[0-9]+\.[0-9]+\.[0-9]+$"
  • Nested Fields: Supports dot notation for nested JSON objects
  • Generic Functions: Reusable field_value() and field_exists() helpers

Testing

  # All policies tested and working
  ./json-field-validator/test.sh 
  ./sbom-freshness/test.sh 

@migmartri

Copy link
Copy Markdown
Member

DCO check is failed, please make sure you signoff your commits, thanks!

Signed-off-by: Daniel Liszka <daniel@chainloop.dev>
@migmartri

Copy link
Copy Markdown
Member

Thanks,

Do you want the json policy to be present just in an example or moved upstream to chainloop platform?

@migmartri migmartri changed the title feat(policy): New json-field-validator policy example, closes PFM-3462 example(policy): New json-field-validator policy example Aug 11, 2025
@migmartri migmartri merged commit 862c2c3 into chainloop-dev:main Aug 11, 2025
13 checks passed
@danlishka danlishka deleted the PFM-3462 branch August 12, 2025 03:21
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.

2 participants