Skip to content
Snippets Groups Projects
Commit 38dc2c64 authored by David Malcolm's avatar David Malcolm
Browse files

SARIF output: fix schema URL [§3.13.3, PR116603]

We were using
  https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json
as the URL for the SARIF 2.1 schema, but this is now a 404.

Update it to the URL listed in the spec (§3.13.3 "$schema property"),
which is:
  https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json
and update the copy in
  gcc/testsuite/lib/sarif-schema-2.1.0.json
used by the "verify-sarif-file" DejaGnu directive to the version found at
that latter URL; the sha256 sum changes
from: 2b19d2358baef0251d7d24e208d05ffabf1b2a3ab5e1b3a816066fc57fd4a7e8
  to: c3b4bb2d6093897483348925aaa73af03b3e3f4bd4ca38cef26dcb4212a2682e

Doing so added a validation error on
  c-c++-common/diagnostic-format-sarif-file-pr111700.c
for which we emit this textual output:
  this-file-does-not-exist.c: warning: #warning message [-Wcpp]
with no line number, and these invalid SARIF regions within the
physical location of the warning:
  "region": {"startColumn": 2,
             "endColumn": 9},
  "contextRegion": {}

This is due to this directive:
  # 0 "this-file-does-not-exist.c"
with line number 0.

The patch fixes this by not creating regions that have startLine <= 0.

gcc/ChangeLog:
	PR other/116603
	* diagnostic-format-sarif.cc (SARIF_SCHEMA): Update URL.
	(sarif_builder::maybe_make_region_object): Don't create regions
	with startLine <= 0.
	(sarif_builder::maybe_make_region_object_for_context): Likewise.

gcc/testsuite/ChangeLog:
	PR other/116603
	* gcc.dg/plugin/diagnostic-test-metadata-sarif.py (test_basics):
	Update expected schema URL.
	* gcc.dg/plugin/diagnostic-test-paths-multithreaded-sarif.py:
	Likewise.
	* gcc.dg/sarif-output/test-include-chain-1.py: Likewise.
	* gcc.dg/sarif-output/test-include-chain-2.py: Likewise.
	* gcc.dg/sarif-output/test-missing-semicolon.py: Likewise.
	* gcc.dg/sarif-output/test-no-diagnostics.py: Likewise.
	* gcc.dg/sarif-output/test-werror.py: Likewise.
	* lib/sarif-schema-2.1.0.json: Update with copy downloaded from
	https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json



Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
parent 1da79de5
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment