Skip to content

Commit

Permalink
GH Action Standards
Browse files Browse the repository at this point in the history
  • Loading branch information
confused-Techie authored and github-actions[bot] committed Mar 27, 2024
1 parent ccb9989 commit 65f2f7a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
26 changes: 18 additions & 8 deletions docs/resources/complexity-report.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Complexity report, 3/27/2024

* Mean per-function logical LOC: 15.080882352941176
* Mean per-function parameter count: 0.1698529411764706
* Mean per-function cyclomatic complexity: 1.2632352941176472
* Mean per-function Halstead effort: 3226.862745343813
* Mean per-module maintainability index: 67.78765469174402
* First-order density: 0.7136678200692042%
* Change cost: 4.541522491349481%
* Mean per-function logical LOC: 14.905797101449275
* Mean per-function parameter count: 0.1673913043478261
* Mean per-function cyclomatic complexity: 1.2594202898550726
* Mean per-function Halstead effort: 3181.0354243656466
* Mean per-module maintainability index: 67.98276367366883
* First-order density: 0.7141356857802983%
* Change cost: 4.452846040747742%
* Core size: 100%

## /home/runner/work/package-backend/package-backend/jest.config.js
Expand Down Expand Up @@ -281,7 +281,7 @@

## /home/runner/work/package-backend/package-backend/src/models/callStack.js

* Physical LOC: 42
* Physical LOC: 83
* Logical LOC: 2
* Mean parameter count: 0
* Cyclomatic complexity: 1
Expand Down Expand Up @@ -809,6 +809,16 @@
* Maintainability index: 86.03073855173344
* Dependency count: 1

## /home/runner/work/package-backend/package-backend/tests/unit/models/callStack.test.js

* Physical LOC: 93
* Logical LOC: 3
* Mean parameter count: 0
* Cyclomatic complexity: 1
* Cyclomatic complexity density: 33.33333333333333%
* Maintainability index: 81.25017444455611
* Dependency count: 1

## /home/runner/work/package-backend/package-backend/tests/database/fixtures/git.createPackage_returns/valid_multi_version.js

* Physical LOC: 44
Expand Down
8 changes: 4 additions & 4 deletions src/models/callStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ module.exports = class CallStack {

// Attempts to remove any sensitive data that may be found within
sanitize(content) {

const badKeys = [
"token",
"password",
"pass",
"auth",
"secret",
"passphrase",
"card"
"card",
];
const githubTokenReg = /(?:gho_|ghp_|github_pat_|ghu_|ghs_|ghr_)/;
const hideString = "*****";
Expand All @@ -46,7 +45,7 @@ module.exports = class CallStack {
}
}

switch(type) {
switch (type) {
case "object":
for (const key in content) {
// Match different possible keys that represent sensitive data
Expand All @@ -63,7 +62,8 @@ module.exports = class CallStack {
// https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-authentication-to-github#githubs-token-formats
if (githubTokenReg.test(content)) {
outContent = hideString;
} else { // More strings to test can be added here
} else {
// More strings to test can be added here
// String seems safe
outContent = content;
}
Expand Down
23 changes: 17 additions & 6 deletions tests/unit/models/callStack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe("Sanitizes content as expected", () => {
const cs = new callStack();

const before = {
value: "Safe data"
value: "Safe data",
};

const after = cs.sanitize(before);
Expand All @@ -18,7 +18,7 @@ describe("Sanitizes content as expected", () => {
const cs = new callStack();

const before = {
token: "super_secret"
token: "super_secret",
};

const after = cs.sanitize(before);
Expand All @@ -39,11 +39,15 @@ describe("Sanitizes content as expected", () => {
test("Removes deeply nested unsafe string", () => {
const cs = new callStack();

const before = { value: { value: { value: { value: "github_pat_value" }}}};
const before = {
value: { value: { value: { value: "github_pat_value" } } },
};

const after = cs.sanitize(before);

expect(after).toEqual({ value: { value: { value: { value: hideValue }}}});
expect(after).toEqual({
value: { value: { value: { value: hideValue } } },
});
});

test("Removes unsafe value from array", () => {
Expand Down Expand Up @@ -73,10 +77,17 @@ describe("Sanitizes content as expected", () => {
{ v3: "gho_oauth_access_token" },
{ v4: "ghu_user_access_token_for_github_app" },
{ v5: "ghs_installation_access_token" },
{ v6: "ghr_refresh_token_for_github_app" }
{ v6: "ghr_refresh_token_for_github_app" },
];
const after = cs.sanitize(before);

expect(after).toEqual([{v1: hideValue}, {v2: hideValue}, {v3: hideValue}, {v4: hideValue}, {v5: hideValue}, {v6: hideValue}]);
expect(after).toEqual([
{ v1: hideValue },
{ v2: hideValue },
{ v3: hideValue },
{ v4: hideValue },
{ v5: hideValue },
{ v6: hideValue },
]);
});
});

0 comments on commit 65f2f7a

Please sign in to comment.