Skip to content

Commit 93bafd2

Browse files
Merge pull request #80 from VirdocsSoftware/release/v2.12.0
release v2.12.0 to main
2 parents 0602cec + e7639eb commit 93bafd2

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

.github/actions/static-analysis/action.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: "Static Analysis"
22
description: "Runs static analysis on the code"
33

4+
inputs:
5+
ignored-accounts:
6+
description: "Comma-separated list of accounts to ignore"
7+
required: false
8+
default: "actions,VirdocsSoftware"
9+
410
runs:
511
using: "composite"
612
steps:
@@ -12,4 +18,6 @@ runs:
1218
echo "With the current working directory: $(pwd)"
1319
node ${{ github.action_path }}/scan_github_actions.js
1420
shell: bash
15-
working-directory: ${{ github.workspace }}
21+
working-directory: ${{ github.workspace }}
22+
env:
23+
IGNORED_ACCOUNTS: ${{ inputs.ignored-accounts }}

.github/actions/static-analysis/scan_github_actions.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
class StaticAnalysis {
2-
constructor(dataProvider, process) {
2+
constructor(dataProvider, process, ignoredAccounts = []) {
33
this.dataProvider = dataProvider;
44
this.process = process;
5+
this.ignoredAccounts = ignoredAccounts;
56
}
67

78
isCommitHash(ref) {
@@ -25,11 +26,15 @@ class StaticAnalysis {
2526

2627
scanFile(filePath) {
2728
const content = this.dataProvider.readFile(filePath);
28-
const regex = /uses:\s*[\w-]+\/[\w-]+@([\w-.]+)/g;
29+
const regex = /uses:\s*([\w-]+\/[\w-]+)@([\w-.]+)/g;
2930
let match;
3031
let warnings = [];
3132
while ((match = regex.exec(content)) !== null) {
32-
const ref = match[1];
33+
const ref = match[2];
34+
const account = match[1].split('/')[0];
35+
if (this.ignoredAccounts.includes(account)) {
36+
continue;
37+
}
3338
if (!this.isCommitHash(ref)) {
3439
warnings.push(`Warning: In file ${filePath}, '${match[0]}' does not use a commit hash.`);
3540
}
@@ -90,7 +95,8 @@ class DataProvider {
9095
const fs = require('fs');
9196
const path = require('path');
9297
const process = require('process');
98+
const ignoredAccounts = (process.env.IGNORED_ACCOUNTS || '').split(',');
9399

94100
const dataProvider = new DataProvider(fs, path);
95-
const staticAnalysis = new StaticAnalysis(dataProvider, process);
101+
const staticAnalysis = new StaticAnalysis(dataProvider, process, ignoredAccounts);
96102
staticAnalysis.run();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-actions",
3-
"version": "2.11.0",
3+
"version": "2.12.0",
44
"description": "Used to store GitHub actions for use across the enterprise",
55
"scripts": {
66
"test": "./tooling/scripts/run_tests.sh",

0 commit comments

Comments
 (0)