-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
csg01123119
committed
Sep 14, 2023
1 parent
5b38931
commit fe8cb63
Showing
4 changed files
with
59 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
node task/detect-secrets | ||
npm run lint-staged |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,43 @@ | ||
const process = require('process'); | ||
const fs = require('fs'); | ||
const files = process.argv.slice(2); | ||
const reg = /['"]LT([A-Za-z0-9+/=]{14}|LT[A-Za-z0-9+/=]{22}|LT[A-Za-z0-9+/=]{28})['"]/; | ||
files.forEach((val, index) => { | ||
try { | ||
const data = fs.readFileSync(val, 'utf8'); | ||
if (reg.test(data)) { | ||
console.error("Don't push accessKeyId/accessKeySecret to repo! ------ File: " + val); | ||
process.exit(-1); | ||
const readline = require('readline-sync'); | ||
|
||
const { execSync } = require('child_process'); | ||
|
||
const getCommandValue = command => { | ||
return execSync(command).toString('utf8').trim(); | ||
}; | ||
|
||
const whiteFiles = ['package-lock.json']; | ||
// Get the list of file names to be submitted | ||
const filenames = getCommandValue('git diff --cached --name-only') | ||
.split('\n') | ||
.filter(item => !!item && !whiteFiles.some(wh => wh === item)); | ||
if (filenames.length === 0) { | ||
console.error('No files to submit'); | ||
process.exit(-1); | ||
} | ||
|
||
const list = []; | ||
filenames.forEach(file => { | ||
if (fs.existsSync(file)) { | ||
const txt = fs.readFileSync(file).toString('utf-8'); | ||
const reg = /([0-9a-z+=]{16}|[0-9a-z+=]{24}|[0-9a-z+=]{30})/gi; | ||
const res = txt.match(reg); | ||
if (res) { | ||
const whiteList = ['peerDependencies', 'hasInstallScript']; | ||
const aks = res.filter(item => !whiteList.some(wh => wh === item)); | ||
if (aks.length > 0) { | ||
list.push(file); // Check if the code contains AK | ||
aks.forEach(item => console.log(item)); | ||
} | ||
} | ||
} catch (err) { | ||
console.error('file error ----' + val); | ||
process.exit(-1); | ||
} | ||
}); | ||
if (list.length > 0) { | ||
console.error('Please check if AK is included in the following files\n'); | ||
list.forEach(item => console.error(item + '\n')); | ||
|
||
const input = readline.question(`Do you want to continue submitting?(y|n)`); | ||
if (/n/i.test(input)) process.exit(-1); | ||
} |