snyk 1.763.0 → 1.764.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1949,25 +1949,32 @@ function extractReportingDescriptor(results) {
1949
1949
  }
1950
1950
  exports.extractReportingDescriptor = extractReportingDescriptor;
1951
1951
  function mapIacTestResponseToSarifResults(issues) {
1952
- return issues.map(({ targetPath, issue }) => ({
1953
- ruleId: issue.id,
1954
- message: {
1955
- text: `This line contains a potential ${issue.severity} severity misconfiguration affecting the ${issue.subType}`,
1956
- },
1957
- locations: [
1958
- {
1959
- physicalLocation: {
1960
- artifactLocation: {
1961
- uri: targetPath,
1962
- uriBaseId: PROJECT_ROOT_KEY,
1963
- },
1964
- region: {
1965
- startLine: issue.lineNumber,
1952
+ return issues.map(({ targetPath, issue }) => {
1953
+ const hasLineNumber = issue.lineNumber && issue.lineNumber >= 0;
1954
+ return {
1955
+ ruleId: issue.id,
1956
+ message: {
1957
+ text: `This line contains a potential ${issue.severity} severity misconfiguration affecting the ${issue.subType}`,
1958
+ },
1959
+ locations: [
1960
+ {
1961
+ physicalLocation: {
1962
+ artifactLocation: {
1963
+ uri: targetPath,
1964
+ uriBaseId: PROJECT_ROOT_KEY,
1965
+ },
1966
+ // We exclude the `region` key when the line number is missing or -1.
1967
+ // https://docs.oasis-open.org/sarif/sarif/v2.0/csprd02/sarif-v2.0-csprd02.html#_Toc10127873
1968
+ ...(hasLineNumber && {
1969
+ region: {
1970
+ startLine: issue.lineNumber,
1971
+ },
1972
+ }),
1966
1973
  },
1967
1974
  },
1968
- },
1969
- ],
1970
- }));
1975
+ ],
1976
+ };
1977
+ });
1971
1978
  }
1972
1979
  exports.mapIacTestResponseToSarifResults = mapIacTestResponseToSarifResults;
1973
1980