advanced-security/filter-sarif

The minimal example is invalid

thibaultcha opened this issue · 3 comments

Hi,

Using the minimal example in our workflow:

-**/*                            # exclusion pattern: DENY ALL
myproject/**                     # inclusion pattern: allows alerts in the path 'myproject/'

Produces the following error:

Run advanced-security/filter-sarif@v1
Run unset LD_PRELOAD
Given patterns:
files: **/*    # exclusion    rules:  DENY ALL (negative)
files: src/**   # inclusion    rules: ** (positive)
Traceback (most recent call last):
  File "/home/runner/work/_actions/advanced-security/filter-sarif/v1/filter_sarif.py", line 147, in <module>
    main()
  File "/home/runner/work/_actions/advanced-security/filter-sarif/v1/filter_sarif.py", line 144, in main
    filter_sarif(args)
  File "/home/runner/work/_actions/advanced-security/filter-sarif/v1/filter_sarif.py", line 99, in filter_sarif
    if uri is None or match_path_and_rule(uri, ruleId, args.patterns):
  File "/home/runner/work/_actions/advanced-security/filter-sarif/v1/filter_sarif.py", line 16, in match_path_and_rule
    if match(rp, rule) and match(fp, path):
  File "/home/runner/work/_actions/advanced-security/filter-sarif/v1/globber.py", line 79, in match
    raise ValueError('** in {} not alone between path separators'.format(pattern))
ValueError: ** in src/**   # inclusion not alone between path separators
Error: Process completed with exit code 1.

Should we fix this example and what is a valid way of including a single directory?

I am trying this for now:

-**/*
myproject/**/*

Thanks!

This worked, for anyone interested:

-**/*
myproject/**/*

Thanks for reporting the issue! I'll see if I get time today to repro this and correct the example

Fixed in #12