Skip to content

Commit 9c14954

Browse files
committed
refactor: modified gileaks rules and general code cleanup
1 parent 72da56e commit 9c14954

File tree

18 files changed

+3370
-452
lines changed

18 files changed

+3370
-452
lines changed

.gitleaksignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/gitleaks_report.json

gitleaks.toml

Lines changed: 2978 additions & 84 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"lodash": "^4.17.21",
6060
"lusca": "^1.7.0",
6161
"moment": "^2.29.4",
62-
"mongodb": "^5.0.0",
62+
"mongodb": "^5.9.2",
6363
"nodemailer": "^6.6.1",
6464
"parse-diff": "^0.11.1",
6565
"passport": "^0.7.0",

proxy.config.json

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
"authorisedList": [
1010
{
1111
"project": "finos",
12-
"name": "git-proxy",
13-
"url": "https://github.com/finos/git-proxy.git"
12+
"name": "git-proxy-test",
13+
"url": "[email protected]:finos/git-proxy-test.git"
14+
},
15+
{
16+
"project": "project name",
17+
"name": "repo name",
18+
"url": "repo url",
19+
"LocalRepoRoot": "specify you local repository path"
1420
}
1521
],
1622
"sink": [
@@ -23,14 +29,14 @@
2329
},
2430
{
2531
"type": "mongo",
26-
"connectionString": "mongodb://localhost:27017/gitproxy",
32+
"connectionString": "mongodb+srv://username:[email protected]/?retryWrites=true&w=majority&appName=Cluster0",
2733
"options": {
2834
"useNewUrlParser": true,
2935
"useUnifiedTopology": true,
3036
"tlsAllowInvalidCertificates": false,
3137
"ssl": true
3238
},
33-
"enabled": false
39+
"enabled": true
3440
}
3541
],
3642
"authentication": [
@@ -78,16 +84,17 @@
7884
"literals": [],
7985
"patterns": [],
8086
"providers": {},
81-
"proxyFileTypes": [".csv", ".jpg", ".xlsx", ".log", ".json"]
87+
"proxyFileTypes": [".csv", ".jpg", ".xlsx", ".log", ".json", ".jpg"]
8288
}
8389
},
8490
"checkForSecrets": {
85-
"enabled": false
91+
"enabled": true
8692
},
8793
"aiMlUsage": {
88-
"enabled": true,
89-
"blockPatterns": ["modelWeights", "largeDatasets", "aiLibraries", "configKeys", "aiFunctions"]
94+
"enabled": true,
95+
"blockPatterns": ["modelWeights", "largeDatasets", "aiLibraries", "configKeys", "aiFunctions"]
9096
}
97+
9198
},
9299
"attestationConfig": {
93100
"questions": [

src/db/file/repo.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ exports.addUserCanPush = async (name, user) => {
7575
exports.addUserCanAuthorise = async (name, user) => {
7676
return new Promise(async (resolve, reject) => {
7777
const repo = await exports.getRepo(name);
78+
console.log('details');
79+
console.log(JSON.stringify(repo));
7880

7981
if (repo.users.canAuthorise.includes(user)) {
8082
resolve(null);

src/proxy/actions/Step.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ class Step {
6666
* @param {*} message
6767
*/
6868
log(message) {
69-
const m = `${this.stepName} - ${message}`;
70-
this.logs.push(m);
71-
console.info(m);
69+
// const m = `${this.stepName} - ${message}`;
70+
// this.logs.push(m);
71+
// console.info(m);
7272
}
7373
}
7474

src/proxy/chain.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@ const pushActionChain = [
55
proc.push.checkRepoInAuthorisedList,
66
proc.push.checkCommitMessages,
77
proc.push.checkAuthorEmails,
8-
proc.push.checkUserPushPermission,
8+
// proc.push.checkUserPushPermission,
99
proc.push.checkIfWaitingAuth,
1010
proc.push.pullRemote,
1111
proc.push.writePack,
1212
proc.push.getDiff,
1313
proc.push.checkForAiMlUsage,
14-
proc.push.checkExifJpeg,
15-
proc.push.checkSensitiveData,
14+
proc.push.checkExifJpeg,
15+
proc.push.checkSensitiveData,
16+
proc.push.checkForSecrets,
1617
proc.push.clearBareClone,
17-
proc.push.checkCryptoImplementation,
1818
proc.push.scanDiff,
1919
proc.push.blockForAuth,
2020
];
2121

22-
2322
const pullActionChain = [proc.push.checkRepoInAuthorisedList];
2423

2524
let pluginsInserted = false;

src/proxy/processors/push-action/checkCommitMessages.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ const exec = async (req, action) => {
5656
const step = new Step('checkCommitMessages');
5757

5858
const uniqueCommitMessages = [...new Set(action.commitData.map((commit) => commit.message))];
59-
console.log({ uniqueCommitMessages });
59+
// console.log({ uniqueCommitMessages });
60+
console.log('This is my commit data \n');
61+
console.log(action);
6062

6163
const illegalMessages = uniqueCommitMessages.filter((message) => !isMessageAllowed(message));
6264
console.log({ illegalMessages });

src/proxy/processors/push-action/checkCryptoImplementation.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const CRYPTO_PATTERNS = {
3737
};
3838

3939
function analyzeCodeForCrypto(diffContent) {
40+
// file access
41+
4042
const issues = [];
4143
// Check for above mentioned cryto Patterns
4244
if(!diffContent) return issues;
@@ -87,14 +89,17 @@ function analyzeCodeForCrypto(diffContent) {
8789
}
8890

8991
const exec = async (req, action) => {
92+
9093
const step = new Step('checkCryptoImplementation');
9194

9295
try {
9396
let hasIssues = false;
9497
const allIssues = [];
95-
98+
console.log("action:",action);
9699
for (const commit of action.commitData) {
97100
const diff = commit.diff || '';
101+
console.log("diff",diff);
102+
98103
const issues = analyzeCodeForCrypto(diff);
99104

100105
if (issues.length > 0) {
@@ -135,6 +140,6 @@ const exec = async (req, action) => {
135140
}
136141
};
137142

138-
// exec.displayName = 'checkCryptoImplementation.exec';
143+
exec.displayName = 'checkCryptoImplementation.exec';
139144
exports.exec = exec;
140145
exports.analyzeCodeForCrypto = analyzeCodeForCrypto;

0 commit comments

Comments
 (0)