Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -270,5 +270,8 @@ website/.docusaurus
# Jetbrains IDE
.idea

# VS COde IDE
.vscode/settings.json

# Generated from testing
/test/fixtures/test-package/package-lock.json
17 changes: 14 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"cors": "^2.8.5",
"diff2html": "^3.4.52",
"env-paths": "^3.0.0",
"escape-string-regexp": "^5.0.0",
"express": "^4.21.2",
"express-http-proxy": "^2.1.2",
"express-rate-limit": "^8.1.0",
Expand Down Expand Up @@ -108,8 +109,8 @@
"@types/passport-local": "^1.0.38",
"@types/react-dom": "^17.0.26",
"@types/react-html-parser": "^2.0.7",
"@types/validator": "^13.15.3",
"@types/sinon": "^17.0.4",
"@types/validator": "^13.15.3",
"@types/yargs": "^17.0.33",
"@vitejs/plugin-react": "^4.7.0",
"chai": "^4.5.0",
Expand Down
4 changes: 3 additions & 1 deletion src/proxy/processors/push-action/scanDiff.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Action, Step } from '../../actions';
import { getCommitConfig, getPrivateOrganizations } from '../../../config';
import parseDiff, { File } from 'parse-diff';
import escapeStringRegexp from 'escape-string-regexp';

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

// Combine all matches (literals, patterns)

const combinedMatches = [
...blockedLiterals.map((literal) => ({
type: BLOCK_TYPE.LITERAL,
match: new RegExp(literal, 'gi'),
match: new RegExp(escapeStringRegexp(literal), 'gi'), //TODO: swap out escapeStringRegexp() for RegExp.escape() when we require node 24
})),
...blockedPatterns.map((pattern) => ({
type: BLOCK_TYPE.PATTERN,
Expand Down
5 changes: 3 additions & 2 deletions test/processors/scanDiff.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ index 8b97e49..de18d43 100644
Project to test gitproxy
+AKIAIOSFODNN7EXAMPLE
+AKIAIOSFODNN8EXAMPLE
+blockedTestLiteral
+emdedded_blocked.Te$t.Literal?
`;
};
describe('Scan commit diff...', async () => {
privateOrganizations[0] = 'private-org-test';
commitConfig.diff = {
block: {
literals: ['blockedTestLiteral'],
//n.b. the example literal includes special chars that would be interpreted as RegEx if not escaped properly
literals: ['blocked.Te$t.Literal?'],
patterns: [],
providers: {
'AWS (Amazon Web Services) Access Key ID':
Expand Down
Loading