Skip to content

Commit 9a339ee

Browse files
authored
Merge branch 'main' into 1185-git-request-classification
2 parents 46c73ab + 6ea37c1 commit 9a339ee

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,5 +270,8 @@ website/.docusaurus
270270
# Jetbrains IDE
271271
.idea
272272

273+
# VS COde IDE
274+
.vscode/settings.json
275+
273276
# Generated from testing
274277
/test/fixtures/test-package/package-lock.json

package-lock.json

Lines changed: 14 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"cors": "^2.8.5",
5656
"diff2html": "^3.4.52",
5757
"env-paths": "^3.0.0",
58+
"escape-string-regexp": "^5.0.0",
5859
"express": "^4.21.2",
5960
"express-http-proxy": "^2.1.2",
6061
"express-rate-limit": "^8.1.0",
@@ -108,8 +109,8 @@
108109
"@types/passport-local": "^1.0.38",
109110
"@types/react-dom": "^17.0.26",
110111
"@types/react-html-parser": "^2.0.7",
111-
"@types/validator": "^13.15.3",
112112
"@types/sinon": "^17.0.4",
113+
"@types/validator": "^13.15.3",
113114
"@types/yargs": "^17.0.33",
114115
"@vitejs/plugin-react": "^4.7.0",
115116
"chai": "^4.5.0",

src/proxy/processors/push-action/scanDiff.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Action, Step } from '../../actions';
22
import { getCommitConfig, getPrivateOrganizations } from '../../../config';
33
import parseDiff, { File } from 'parse-diff';
4+
import escapeStringRegexp from 'escape-string-regexp';
45

56
const commitConfig = getCommitConfig();
67
const privateOrganizations = getPrivateOrganizations();
@@ -75,10 +76,11 @@ const combineMatches = (organization: string) => {
7576
: Object.entries(commitConfig?.diff?.block?.providers ?? []);
7677

7778
// Combine all matches (literals, patterns)
79+
7880
const combinedMatches = [
7981
...blockedLiterals.map((literal) => ({
8082
type: BLOCK_TYPE.LITERAL,
81-
match: new RegExp(literal, 'gi'),
83+
match: new RegExp(escapeStringRegexp(literal), 'gi'), //TODO: swap out escapeStringRegexp() for RegExp.escape() when we require node 24
8284
})),
8385
...blockedPatterns.map((pattern) => ({
8486
type: BLOCK_TYPE.PATTERN,

test/processors/scanDiff.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ index 8b97e49..de18d43 100644
5353
Project to test gitproxy
5454
+AKIAIOSFODNN7EXAMPLE
5555
+AKIAIOSFODNN8EXAMPLE
56-
+blockedTestLiteral
56+
+emdedded_blocked.Te$t.Literal?
5757
`;
5858
};
5959
describe('Scan commit diff...', async () => {
6060
privateOrganizations[0] = 'private-org-test';
6161
commitConfig.diff = {
6262
block: {
63-
literals: ['blockedTestLiteral'],
63+
//n.b. the example literal includes special chars that would be interpreted as RegEx if not escaped properly
64+
literals: ['blocked.Te$t.Literal?'],
6465
patterns: [],
6566
providers: {
6667
'AWS (Amazon Web Services) Access Key ID':

0 commit comments

Comments
 (0)