Commit Graph

29 Commits

Author SHA1 Message Date
Michael Hohn
bd9460dd61 Remove old comment 2023-07-27 09:34:17 -07:00
Michael Hohn
c299321ab8 Remove repls; add scripts/test-vcp.sh 2023-07-13 16:03:01 -07:00
Michael Hohn
68b43e0514 wip: debug and get automationDetails into CSV output 2023-07-12 17:04:23 -07:00
Michael Hohn
606912c8c3 Merge remote-tracking branch 'refs/remotes/origin/master' 2023-07-10 09:03:45 -07:00
Kristen Newbury
9407e5b00f Add ability to read automationDetails.id if present 2023-05-17 15:23:19 -04:00
Kristen Newbury
e2501b94a9 Fix fulldescription missing patch
previous patch added nonunique placeholder
but must be unique
2023-05-15 13:10:07 -04:00
Kristen Newbury
1e1305bb25 Fix CLI sarif consumption for properties:
fullDescription
primaryLocationStartColumnFingerprint
2023-03-02 12:43:42 -05:00
Kristen Newbury
1be65372e8 Fix CLI sarif consumption for property - description 2023-03-02 11:16:27 -05:00
Michael Hohn
e62c351029 Merge remote-tracking branch 'kristen/main' 2023-01-23 13:14:14 -08:00
Kristen Newbury
fc2c6bac99 Add capability to read sourceLanguage if exists in CLI sarif
otherwise dummy val
previously assumed never present in CLI sarif
2023-01-05 12:50:54 -05:00
Kristen Newbury
04a5aae14d Add CLI support
enabled by -f flag with CLI value
tested on sarif from CodeQL CLIs:
2.6.3, 2.9.4, 2.11.4
MUST contain versionControlProvenance property however
2022-12-15 19:12:58 -05:00
Kristen Newbury
69f5ef09a4 Merge branch 'addCLISignature' 2022-12-13 12:22:43 -05:00
Kristen Newbury
2ba9593d70 Add CLI support
enabled by -f flag with CLI value
tested on sarif from CodeQL CLIs:
2.6.3, 2.9.4, 2.11.4
MUST contain versionControlProvenance property however
2022-12-13 12:14:32 -05:00
Kristen Newbury
fb0e1b9c1c Change sarif sig severity to problem.severity
and rm redundant table col for kind
2022-12-02 16:00:40 -05:00
Michael Hohn
f5e258de52 Enhance the fillsig() routines to supplement lgtm.com/lgtm enterprise signature differences 2022-05-30 00:08:09 -07:00
Michael Hohn
0f070a6ae4 sarif-extract-multi: extract combined tables from multiple sarif files
This command introduces a new tree structure that pulls in a collection
of sarif files.  In yaml format, an example is

    - creation_date: '2021-12-09'   # Repository creation date
      primary_language: javascript  # By lines of code
      project_name: treeio/treeio   # Repo name-short name
      query_commit_id: fa9571646c   # Commit id for custom (non-library) queries
      sarif_content: {}             # The sarif content will be attached here
      sarif_file_name: 2021-12-09/results.sarif # Path to sarif file
      scan_start_date: '2021-12-09'             # Beginning date/time of scan
      scan_stop_date:  '2021-12-10'             # End date/time of scan
      tool_name: codeql
      tool_version: v1.27

    - creation_date: '2022-02-25'
      primary_language: javascript
      ...

At run time,

    cd ~/local/sarif-cli/data/treeio
    sarif-extract-multi multi-sarif-01.json test-multi-table

will load the specified sarif files and put them in place of
`sarif_content`, then build tables against the new signature found in
sarif_cli/signature_multi.py, and merge those into 6 larger tables.  The
exported tables are

    artifacts.csv  path-problem.csv  project.csv
    codeflows.csv  problem.csv       related-locations.csv

and they have join keys for further operations.

The new typegraph is rendered in

    notes/typegraph-multi.pdf

using the instructions in

    sarif_cli/signature_multi.py
2022-03-11 23:00:53 -08:00
Michael Hohn
ad738abed3 sarif-extract-tables: also output relatedLocations table
With --related-locations,

    ../../bin/sarif-results-summary -r results.sarif

produces the details

    RESULT: static/js/tinymce/jscripts/tiny_mce/plugins/paste/editor_plugin_src.js:722:
    72:722:73: Character ''' is repeated [here](1) in the same character class.
    Character ''' is repeated [here](2) in the same character class.
    Character ''' is repeated [here](3) in the same character class.
    REFERENCE: static/js/tinymce/jscripts/tiny_mce/plugins/paste/editor_plugin_src.js:722:74:722:75: here
    REFERENCE: static/js/tinymce/jscripts/tiny_mce/plugins/paste/editor_plugin_src.js:722:76:722:77: here
    REFERENCE: static/js/tinymce/jscripts/tiny_mce/plugins/paste/editor_plugin_src.js:722:78:722:79: here

Via
    ../../bin/sarif-extract-tables results.sarif tables

sarif-extract-tables now produces two output tables,

    tables/
    ├── messages.csv
    └── relatedLocations.csv

that contain the relevant information and can be joined or otherwise combined on
the struct_id_4055 key.

For example, adding to the end of sarif-extract-tables:
    import IPython
    IPython.embed()

    msg = d2[d2.message.str.startswith("Character ''' is repeated [here]")]
    dr3[dr3.struct_id_4055 == msg.struct_id_4055.values[0]]

    In [24]: msg
    Out[24]:
         struct_id_4055  ...                                            message
    180      4796917312  ...  Character ''' is repeated [here](1) in the sam...

    [1 rows x 7 columns]

    In [25]: dr3[dr3.struct_id_4055 == msg.struct_id_4055.values[0]]
    Out[25]:
         struct_id_4055                                                uri  startLine  startColumn  endLine  endColumn message
    180      4796917312  static/js/tinymce/jscripts/tiny_mce/plugins/pa...        722           74      722         75    here
    181      4796917312  static/js/tinymce/jscripts/tiny_mce/plugins/pa...        722           76      722         77    here
    182      4796917312  static/js/tinymce/jscripts/tiny_mce/plugins/pa...        722           78      722         79    here

or manually from the shell:

    # pick up the struct_id_4055:
    0:$ grep "static.*Character ''' is repeated \[here\]" tables/messages.csv
    180,4927448704,static/js/tinymce/jscripts/tiny_mce/plugins/paste/editor_plugin_src.js,722,72,722,73,"Character ''' is repeated [here](1) in the same character class.

    # and find relatedLocations:
    0:$ grep 4927448704 tables/relatedLocations.csv
    180,4927448704,static/js/tinymce/jscripts/tiny_mce/plugins/paste/editor_plugin_src.js,722,74,722,75,here
    181,4927448704,static/js/tinymce/jscripts/tiny_mce/plugins/paste/editor_plugin_src.js,722,76,722,77,here
    182,4927448704,static/js/tinymce/jscripts/tiny_mce/plugins/paste/editor_plugin_src.js,722,78,722,79,here

Changes:
- Introduce scli-dyys, a random id string for later identification and removal of
  dummy table rows.

- Keep the struct_id_4055 column to join tables as needed.

- Output is now written to a directory as there are always multiple files.
2022-02-16 17:03:58 -08:00
Michael Hohn
cf8096446b sarif-to-dot: cleanup for and preparation for sarif table extraction 2022-02-01 22:42:25 -08:00
Michael Hohn
119f9a5c18 sarif-to-dot: add more support for --fill-structure option
Expand

  ('Struct4827', ('struct', ('physicalLocation', 'Struct4963'))),

to have fields

  ( 'Struct2683',
    ( 'struct',
      ('id', 'Int'),
      ('message', 'Struct2774'),
      ('physicalLocation', 'Struct4963')))

and avoid a redundant table.
2022-01-27 18:55:02 -08:00
Michael Hohn
eb53ede8b1 sarif-to-dot: add more support for --fill-structure option
Common to all:
| ('locations', 'Array008')            |
| ('message', 'Struct009')             |
| ('partialFingerprints', 'Struct010') |
| ('rule', 'Struct011')                |
| ('ruleId', 'String'),                |
| ('ruleIndex', 'Int')))               |

Only some problems and flow problems have
| ('relatedLocations', 'Array014') |

Add dummy value for relatedLocations to reduce to two result categories,
@kind flow problem and @kind problem.
2022-01-27 18:18:43 -08:00
Michael Hohn
80b22001ce sarif-to-dot: make signature names order-independent
To create entire subtrees conforming to a signature, first make the
signature names order-independent.  Use hashes to name the signatures.
2022-01-27 17:53:14 -08:00
Michael Hohn
0b13a297a5 sarif-to-dot: add more support for --fill-structure option
Ensure

    ('Array003', ('array', (0, 'String'))),

is always present, collapse the following into one:

( 'Struct032',
  ( 'struct',
    ('artifacts', 'Array002'),
    ('columnKind', 'String'),
    ('newlineSequences', 'Array003'),
    ('properties', 'Struct004'),
    ('results', 'Array023'),
    ('tool', 'Struct029'),
    ('versionControlProvenance', 'Array031'))),

( 'Struct033',
  ( 'struct',
    ('artifacts', 'Array002'),
    ('columnKind', 'String'),
    ('properties', 'Struct004'),
    ('results', 'Array023'),
    ('tool', 'Struct029'),
    ('versionControlProvenance', 'Array031')))
2022-01-26 22:27:07 -08:00
Michael Hohn
2adf0dfa21 sarif-to-dot: increase graph ranksep to get intelligible edges 2022-01-26 16:15:42 -08:00
Michael Hohn
2c98cf0d41 sarif-to-dot: add more support for --fill-structure option
When both

   ('message', 'Struct009'),
   ('physicalLocation', 'Struct006'))),

are present, ensure

      ('id', 'Int'),

also is.
2022-01-26 16:06:15 -08:00
Michael Hohn
2b75988b9a sarif-to-dot: add more support for --fill-structure option
Expand all 'properties' objects to common signature; instead of the 3
entries, get one:

( 'struct',
('kind', 'String'),
('precision', 'String'),
('severity', 'String'),
('tags', 'Array003')))

( 'struct',
('kind', 'String'),
('precision', 'String'),
('security-severity', 'String'),
('severity', 'String'),
('tags', 'Array003'))

( 'struct',
('kind', 'String'),
('precision', 'String'),
('severity', 'String'),
('sub-severity', 'String'),
('tags', 'Array003'))
2022-01-26 15:41:26 -08:00
Michael Hohn
153eba8346 sarif-to-dot: to reduce graph clutter, add option --no-edges-to-scalars 2022-01-26 00:41:31 -08:00
Michael Hohn
d7d566c5db sarif-to-dot: add more support for --fill-structure option
Collapse multipl 'physicalLocation's into one; from
 ( 'Struct006',
    ('struct', ('artifactLocation', 'Struct000'), ('region', 'Struct005'))),

 ('Struct036', ('struct', ('artifactLocation', 'Struct000'))),

to

 ( 'Struct006',
    ('struct', ('artifactLocation', 'Struct000'), ('region', 'Struct005'))),
2022-01-25 23:43:43 -08:00
Michael Hohn
b816705574 sarif-to-dot: add --fill-structure option and initial library support
This collapses the rightmost column of the signature output from

    ../../bin/sarif-to-dot -u -t -d -f results.sarif | dot -Tpdf

which has multiple distinct entries

 ('Struct030', ('struct', ('endColumn', 'Int'), ('startLine', 'Int'))),
 ( 'Struct016',
    ( 'struct',
      ('endColumn', 'Int'),
      ('startColumn', 'Int'),
      ('startLine', 'Int'))),
 ( 'Struct025',
    ( 'struct',
      ('endColumn', 'Int'),
      ('endLine', 'Int'),
      ('startColumn', 'Int'),
      ('startLine', 'Int'))),
 ('Struct030', ('struct', ('endColumn', 'Int'), ('startLine', 'Int'))),

to a single entry,

  ( 'Struct005',
    ( 'struct',
      ('endColumn', 'Int'),
      ('endLine', 'Int'),
      ('startColumn', 'Int'),
      ('startLine', 'Int'))),

when using

    ../../bin/sarif-to-dot results.sarif -u -t -f
2022-01-25 23:18:20 -08:00
Michael Hohn
edfe1f3363 sarif-to-dot: move signature functions into their own module 2022-01-25 17:57:44 -08:00