mirror of
https://github.com/github/codeql-action.git
synced 2025-12-23 07:40:10 +08:00
Compare commits
19 Commits
v1.0.6
...
codeql-bun
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa857eb53f | ||
|
|
ecc548b556 | ||
|
|
2f3ec1f9f1 | ||
|
|
554f1b3765 | ||
|
|
934fb86c58 | ||
|
|
e145aa414e | ||
|
|
36f860f369 | ||
|
|
63603427ef | ||
|
|
bf54da2db0 | ||
|
|
592af860c5 | ||
|
|
60211eb74c | ||
|
|
3428407b4d | ||
|
|
d6fc379360 | ||
|
|
11d56696ec | ||
|
|
47cfd760cf | ||
|
|
01b1510da2 | ||
|
|
0afedcafa7 | ||
|
|
2a20b15eca | ||
|
|
0d0f0ef80e |
9
.github/depandabot.yml
vendored
Normal file
9
.github/depandabot.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
day: "thursday" # Gives us a working day to merge this before our typical release
|
||||||
|
labels:
|
||||||
|
- "Update dependencies"
|
||||||
2
.github/workflows/pr-checks.yml
vendored
2
.github/workflows/pr-checks.yml
vendored
@@ -27,7 +27,7 @@ jobs:
|
|||||||
run: .github/workflows/script/check-js.sh
|
run: .github/workflows/script/check-js.sh
|
||||||
|
|
||||||
check-node-modules:
|
check-node-modules:
|
||||||
runs-on: ubuntu-latest
|
runs-on: macos-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ if [ ! -z "$(git status --porcelain)" ]; then
|
|||||||
>&2 echo "Failed: Repo should be clean before testing!"
|
>&2 echo "Failed: Repo should be clean before testing!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
sudo npm install --force -g npm@latest
|
||||||
# Reinstall modules and then clean to remove absolute paths
|
# Reinstall modules and then clean to remove absolute paths
|
||||||
# Use 'npm ci' instead of 'npm install' as this is intended to be reproducible
|
# Use 'npm ci' instead of 'npm install' as this is intended to be reproducible
|
||||||
npm ci
|
npm ci
|
||||||
|
|||||||
39
.github/workflows/update-dependencies.yml
vendored
Normal file
39
.github/workflows/update-dependencies.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: Update dependencies
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [opened, synchronize, reopened, labeled]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update:
|
||||||
|
name: Update dependencies
|
||||||
|
runs-on: macos-latest
|
||||||
|
if: contains(github.event.pull_request.labels.*.name, 'Update dependencies')
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Remove PR label
|
||||||
|
env:
|
||||||
|
REPOSITORY: '${{ github.repository }}'
|
||||||
|
PR_NUMBER: '${{ github.event.pull_request.number }}'
|
||||||
|
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
|
run: |
|
||||||
|
gh api "repos/$REPOSITORY/issues/$PR_NUMBER/labels/Update%20dependencies" -X DELETE
|
||||||
|
|
||||||
|
- name: Push updated dependencies
|
||||||
|
env:
|
||||||
|
BRANCH: '${{ github.head_ref }}'
|
||||||
|
run: |
|
||||||
|
git fetch
|
||||||
|
git checkout $BRANCH
|
||||||
|
sudo npm install --force -g npm@latest
|
||||||
|
npm install
|
||||||
|
npm ci
|
||||||
|
npm run removeNPMAbsolutePaths
|
||||||
|
if [ ! -z "$(git status --porcelain)" ]; then
|
||||||
|
git config --global user.email "github-actions@github.com"
|
||||||
|
git config --global user.name "github-actions[bot]"
|
||||||
|
git add node_modules
|
||||||
|
git commit -am "Update checked-in dependencies"
|
||||||
|
git push origin "$BRANCH"
|
||||||
|
fi
|
||||||
@@ -1,5 +1,13 @@
|
|||||||
# CodeQL Action and CodeQL Runner Changelog
|
# CodeQL Action and CodeQL Runner Changelog
|
||||||
|
|
||||||
|
## [UNRELEASED]
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
|
## 1.0.7 - 21 Jul 2021
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
## 1.0.6 - 19 Jul 2021
|
## 1.0.6 - 19 Jul 2021
|
||||||
|
|
||||||
- The `init` step of the Action now supports a `source-root` input as a path to the root source-code directory. By default, the path is relative to `$GITHUB_WORKSPACE`. [#607](https://github.com/github/codeql-action/pull/607)
|
- The `init` step of the Action now supports a `source-root` input as a path to the root source-code directory. By default, the path is relative to `$GITHUB_WORKSPACE`. [#607](https://github.com/github/codeql-action/pull/607)
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ name: "Code Scanning - Action"
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
schedule:
|
schedule:
|
||||||
# ┌───────────── minute (0 - 59)
|
# ┌───────────── minute (0 - 59)
|
||||||
# │ ┌───────────── hour (0 - 23)
|
# │ ┌───────────── hour (0 - 23)
|
||||||
|
|||||||
11
lib/analyze.js
generated
11
lib/analyze.js
generated
@@ -219,12 +219,14 @@ async function runCleanup(config, cleanupLevel, logger) {
|
|||||||
}
|
}
|
||||||
exports.runCleanup = runCleanup;
|
exports.runCleanup = runCleanup;
|
||||||
async function injectLinesOfCode(sarifFile, language, locPromise) {
|
async function injectLinesOfCode(sarifFile, language, locPromise) {
|
||||||
|
var _a;
|
||||||
const lineCounts = await locPromise;
|
const lineCounts = await locPromise;
|
||||||
const idPrefix = count_loc_1.getIdPrefix(language);
|
const idPrefix = count_loc_1.getIdPrefix(language);
|
||||||
if (language in lineCounts) {
|
if (language in lineCounts) {
|
||||||
const sarif = JSON.parse(fs.readFileSync(sarifFile, "utf8"));
|
const sarif = JSON.parse(fs.readFileSync(sarifFile, "utf8"));
|
||||||
if (Array.isArray(sarif.runs)) {
|
if (Array.isArray(sarif.runs)) {
|
||||||
for (const run of sarif.runs) {
|
for (const run of sarif.runs) {
|
||||||
|
// Old style: Baseline is inserted when rule ID has suffix /summary/lines-of-code
|
||||||
const ruleId = `${idPrefix}/summary/lines-of-code`;
|
const ruleId = `${idPrefix}/summary/lines-of-code`;
|
||||||
run.properties = run.properties || {};
|
run.properties = run.properties || {};
|
||||||
run.properties.metricResults = run.properties.metricResults || [];
|
run.properties.metricResults = run.properties.metricResults || [];
|
||||||
@@ -235,6 +237,15 @@ async function injectLinesOfCode(sarifFile, language, locPromise) {
|
|||||||
if (rule) {
|
if (rule) {
|
||||||
rule.baseline = lineCounts[language];
|
rule.baseline = lineCounts[language];
|
||||||
}
|
}
|
||||||
|
// New style: Baseline is inserted when matching rule has tag lines-of-code
|
||||||
|
for (const metric of run.properties.metricResults) {
|
||||||
|
if (metric.rule && metric.rule.toolComponent) {
|
||||||
|
const matchingRule = run.tool.extensions[metric.rule.toolComponent.index].rules[metric.rule.index];
|
||||||
|
if ((_a = matchingRule.properties.tags) === null || _a === void 0 ? void 0 : _a.includes("lines-of-code")) {
|
||||||
|
metric.baseline = lineCounts[language];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fs.writeFileSync(sarifFile, JSON.stringify(sarif));
|
fs.writeFileSync(sarifFile, JSON.stringify(sarif));
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
43
lib/analyze.test.js
generated
43
lib/analyze.test.js
generated
@@ -88,6 +88,35 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// variant 3 references a rule with the lines-of-code tag
|
||||||
|
{
|
||||||
|
tool: {
|
||||||
|
extensions: [
|
||||||
|
{
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
properties: {
|
||||||
|
tags: ["lines-of-code"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
properties: {
|
||||||
|
metricResults: [
|
||||||
|
{
|
||||||
|
rule: {
|
||||||
|
index: 0,
|
||||||
|
toolComponent: {
|
||||||
|
index: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
value: 123,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
{},
|
{},
|
||||||
],
|
],
|
||||||
}));
|
}));
|
||||||
@@ -180,8 +209,20 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
baseline: lineCount,
|
baseline: lineCount,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
t.deepEqual(sarif.runs[2].properties.metricResults, [
|
||||||
|
{
|
||||||
|
rule: {
|
||||||
|
index: 0,
|
||||||
|
toolComponent: {
|
||||||
|
index: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
value: 123,
|
||||||
|
baseline: lineCount,
|
||||||
|
},
|
||||||
|
]);
|
||||||
// when the rule doesn't exist, it should not be added
|
// when the rule doesn't exist, it should not be added
|
||||||
t.deepEqual(sarif.runs[2].properties.metricResults, []);
|
t.deepEqual(sarif.runs[3].properties.metricResults, []);
|
||||||
}
|
}
|
||||||
function verifyQuerySuites(tmpDir) {
|
function verifyQuerySuites(tmpDir) {
|
||||||
const qlsContent = [
|
const qlsContent = [
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
6
node_modules/.package-lock.json
generated
vendored
6
node_modules/.package-lock.json
generated
vendored
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "1.0.6",
|
"version": "1.0.8",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
@@ -1243,7 +1243,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"anymatch": "~3.1.1",
|
"anymatch": "~3.1.1",
|
||||||
"braces": "~3.0.2",
|
"braces": "~3.0.2",
|
||||||
"fsevents": "~2.1.2",
|
|
||||||
"glob-parent": "~5.1.0",
|
"glob-parent": "~5.1.0",
|
||||||
"is-binary-path": "~2.1.0",
|
"is-binary-path": "~2.1.0",
|
||||||
"is-glob": "~4.0.1",
|
"is-glob": "~4.0.1",
|
||||||
@@ -3220,9 +3219,6 @@
|
|||||||
"node_modules/jsonfile": {
|
"node_modules/jsonfile": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
|
||||||
"graceful-fs": "^4.1.6"
|
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"graceful-fs": "^4.1.6"
|
"graceful-fs": "^4.1.6"
|
||||||
}
|
}
|
||||||
|
|||||||
7
node_modules/glob-parent/CHANGELOG.md
generated
vendored
7
node_modules/glob-parent/CHANGELOG.md
generated
vendored
@@ -4,6 +4,13 @@
|
|||||||
|
|
||||||
- eliminate ReDoS ([#36](https://github.com/gulpjs/glob-parent/issues/36)) ([f923116](https://github.com/gulpjs/glob-parent/commit/f9231168b0041fea3f8f954b3cceb56269fc6366))
|
- eliminate ReDoS ([#36](https://github.com/gulpjs/glob-parent/issues/36)) ([f923116](https://github.com/gulpjs/glob-parent/commit/f9231168b0041fea3f8f954b3cceb56269fc6366))
|
||||||
|
|
||||||
|
### [6.0.1](https://www.github.com/gulpjs/glob-parent/compare/v6.0.0...v6.0.1) (2021-07-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Resolve ReDoS vulnerability from CVE-2021-35065 ([#49](https://www.github.com/gulpjs/glob-parent/issues/49)) ([3e9f04a](https://www.github.com/gulpjs/glob-parent/commit/3e9f04a3b4349db7e1962d87c9a7398cda51f339))
|
||||||
|
|
||||||
## [6.0.0](https://www.github.com/gulpjs/glob-parent/compare/v5.1.2...v6.0.0) (2021-05-03)
|
## [6.0.0](https://www.github.com/gulpjs/glob-parent/compare/v5.1.2...v6.0.0) (2021-05-03)
|
||||||
|
|
||||||
### ⚠ BREAKING CHANGES
|
### ⚠ BREAKING CHANGES
|
||||||
|
|||||||
26
node_modules/glob-parent/index.js
generated
vendored
26
node_modules/glob-parent/index.js
generated
vendored
@@ -6,7 +6,6 @@ var isWin32 = require('os').platform() === 'win32';
|
|||||||
|
|
||||||
var slash = '/';
|
var slash = '/';
|
||||||
var backslash = /\\/g;
|
var backslash = /\\/g;
|
||||||
var enclosure = /[{[].*\/.*[}\]]$/;
|
|
||||||
var globby = /(^|[^\\])([{[]|\([^)]+$)/;
|
var globby = /(^|[^\\])([{[]|\([^)]+$)/;
|
||||||
var escaped = /\\([!*?|[\](){}])/g;
|
var escaped = /\\([!*?|[\](){}])/g;
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ module.exports = function globParent(str, opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// special case for strings ending in enclosure containing path separator
|
// special case for strings ending in enclosure containing path separator
|
||||||
if (enclosure.test(str)) {
|
if (isEnclosure(str)) {
|
||||||
str += slash;
|
str += slash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,3 +38,26 @@ module.exports = function globParent(str, opts) {
|
|||||||
// remove escape chars and return result
|
// remove escape chars and return result
|
||||||
return str.replace(escaped, '$1');
|
return str.replace(escaped, '$1');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function isEnclosure(str) {
|
||||||
|
var lastChar = str.slice(-1);
|
||||||
|
|
||||||
|
var enclosureStart;
|
||||||
|
switch (lastChar) {
|
||||||
|
case '}':
|
||||||
|
enclosureStart = '{';
|
||||||
|
break;
|
||||||
|
case ']':
|
||||||
|
enclosureStart = '[';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var foundIndex = str.indexOf(enclosureStart);
|
||||||
|
if (foundIndex < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return str.slice(foundIndex + 1, -1).includes(slash);
|
||||||
|
}
|
||||||
|
|||||||
2
node_modules/glob-parent/package.json
generated
vendored
2
node_modules/glob-parent/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "glob-parent",
|
"name": "glob-parent",
|
||||||
"version": "6.0.0",
|
"version": "6.0.1",
|
||||||
"description": "Extract the non-magic parent path from a glob string.",
|
"description": "Extract the non-magic parent path from a glob string.",
|
||||||
"author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",
|
"author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "1.0.6",
|
"version": "1.0.8",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "1.0.6",
|
"version": "1.0.8",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "^0.5.1",
|
"@actions/artifact": "^0.5.1",
|
||||||
@@ -1297,7 +1297,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"anymatch": "~3.1.1",
|
"anymatch": "~3.1.1",
|
||||||
"braces": "~3.0.2",
|
"braces": "~3.0.2",
|
||||||
"fsevents": "~2.1.2",
|
|
||||||
"glob-parent": "~5.1.0",
|
"glob-parent": "~5.1.0",
|
||||||
"is-binary-path": "~2.1.0",
|
"is-binary-path": "~2.1.0",
|
||||||
"is-glob": "~4.0.1",
|
"is-glob": "~4.0.1",
|
||||||
@@ -3274,9 +3273,6 @@
|
|||||||
"node_modules/jsonfile": {
|
"node_modules/jsonfile": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
|
||||||
"graceful-fs": "^4.1.6"
|
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"graceful-fs": "^4.1.6"
|
"graceful-fs": "^4.1.6"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "1.0.6",
|
"version": "1.0.8",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "CodeQL action",
|
"description": "CodeQL action",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
2
runner/package-lock.json
generated
2
runner/package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql-runner",
|
"name": "codeql-runner",
|
||||||
"version": "1.0.6",
|
"version": "1.0.8",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql-runner",
|
"name": "codeql-runner",
|
||||||
"version": "1.0.6",
|
"version": "1.0.8",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "CodeQL runner",
|
"description": "CodeQL runner",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -94,6 +94,35 @@ test("status report fields and search path setting", async (t) => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// variant 3 references a rule with the lines-of-code tag
|
||||||
|
{
|
||||||
|
tool: {
|
||||||
|
extensions: [
|
||||||
|
{
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
properties: {
|
||||||
|
tags: ["lines-of-code"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
properties: {
|
||||||
|
metricResults: [
|
||||||
|
{
|
||||||
|
rule: {
|
||||||
|
index: 0,
|
||||||
|
toolComponent: {
|
||||||
|
index: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
value: 123,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
{},
|
{},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@@ -233,8 +262,20 @@ test("status report fields and search path setting", async (t) => {
|
|||||||
baseline: lineCount,
|
baseline: lineCount,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
t.deepEqual(sarif.runs[2].properties.metricResults, [
|
||||||
|
{
|
||||||
|
rule: {
|
||||||
|
index: 0,
|
||||||
|
toolComponent: {
|
||||||
|
index: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
value: 123,
|
||||||
|
baseline: lineCount,
|
||||||
|
},
|
||||||
|
]);
|
||||||
// when the rule doesn't exist, it should not be added
|
// when the rule doesn't exist, it should not be added
|
||||||
t.deepEqual(sarif.runs[2].properties.metricResults, []);
|
t.deepEqual(sarif.runs[3].properties.metricResults, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
function verifyQuerySuites(tmpDir: string) {
|
function verifyQuerySuites(tmpDir: string) {
|
||||||
|
|||||||
@@ -415,8 +415,10 @@ async function injectLinesOfCode(
|
|||||||
const idPrefix = getIdPrefix(language);
|
const idPrefix = getIdPrefix(language);
|
||||||
if (language in lineCounts) {
|
if (language in lineCounts) {
|
||||||
const sarif = JSON.parse(fs.readFileSync(sarifFile, "utf8"));
|
const sarif = JSON.parse(fs.readFileSync(sarifFile, "utf8"));
|
||||||
|
|
||||||
if (Array.isArray(sarif.runs)) {
|
if (Array.isArray(sarif.runs)) {
|
||||||
for (const run of sarif.runs) {
|
for (const run of sarif.runs) {
|
||||||
|
// Old style: Baseline is inserted when rule ID has suffix /summary/lines-of-code
|
||||||
const ruleId = `${idPrefix}/summary/lines-of-code`;
|
const ruleId = `${idPrefix}/summary/lines-of-code`;
|
||||||
run.properties = run.properties || {};
|
run.properties = run.properties || {};
|
||||||
run.properties.metricResults = run.properties.metricResults || [];
|
run.properties.metricResults = run.properties.metricResults || [];
|
||||||
@@ -428,8 +430,22 @@ async function injectLinesOfCode(
|
|||||||
if (rule) {
|
if (rule) {
|
||||||
rule.baseline = lineCounts[language];
|
rule.baseline = lineCounts[language];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New style: Baseline is inserted when matching rule has tag lines-of-code
|
||||||
|
for (const metric of run.properties.metricResults) {
|
||||||
|
if (metric.rule && metric.rule.toolComponent) {
|
||||||
|
const matchingRule =
|
||||||
|
run.tool.extensions[metric.rule.toolComponent.index].rules[
|
||||||
|
metric.rule.index
|
||||||
|
];
|
||||||
|
if (matchingRule.properties.tags?.includes("lines-of-code")) {
|
||||||
|
metric.baseline = lineCounts[language];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFileSync(sarifFile, JSON.stringify(sarif));
|
fs.writeFileSync(sarifFile, JSON.stringify(sarif));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user