Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #230 from galasa-dev/issue-1884-detect-secrets
Browse files Browse the repository at this point in the history
created detect-secrets baseline and added call to build locally script
  • Loading branch information
KirbyKatcher authored Jun 3, 2024
2 parents 80df180 + 93894d0 commit caf4920
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 1 deletion.
85 changes: 85 additions & 0 deletions .secrets.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"exclude": {
"files": "^.secrets.baseline$",
"lines": null
},
"generated_at": "2024-06-03T10:11:05Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
},
{
"name": "ArtifactoryDetector"
},
{
"name": "AzureStorageKeyDetector"
},
{
"base64_limit": 4.5,
"name": "Base64HighEntropyString"
},
{
"name": "BasicAuthDetector"
},
{
"name": "BoxDetector"
},
{
"name": "CloudantDetector"
},
{
"ghe_instance": "github.ibm.com",
"name": "GheDetector"
},
{
"name": "GitHubTokenDetector"
},
{
"hex_limit": 3,
"name": "HexHighEntropyString"
},
{
"name": "IbmCloudIamDetector"
},
{
"name": "IbmCosHmacDetector"
},
{
"name": "JwtTokenDetector"
},
{
"keyword_exclude": null,
"name": "KeywordDetector"
},
{
"name": "MailchimpDetector"
},
{
"name": "NpmDetector"
},
{
"name": "PrivateKeyDetector"
},
{
"name": "SlackDetector"
},
{
"name": "SoftlayerDetector"
},
{
"name": "SquareOAuthDetector"
},
{
"name": "StripeDetector"
},
{
"name": "TwilioKeyDetector"
}
],
"results": {},
"version": "0.13.1+ibm.62.dss",
"word_list": {
"file": null,
"hash": null
}
}
37 changes: 36 additions & 1 deletion build-locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ LOGS_DIR - Optional. Where logs are placed. Defaults to creating a temporary dir
EOF
}

function check_exit_code () {
# This function takes 3 parameters in the form:
# $1 an integer value of the expected exit code
# $2 an error message to display if $1 is not equal to 0
if [[ "$1" != "0" ]]; then
error "$2"
exit 1
fi
}

#-----------------------------------------------------------------------------------------
# Process parameters
#-----------------------------------------------------------------------------------------
Expand Down Expand Up @@ -180,7 +190,8 @@ function build_with_gradle {
${goals}"
info "Using command: $cmd"
$cmd 2>&1 > ${log_file}
rc=$? ; if [[ "${rc}" != "0" ]]; then cat ${log_file} ; error "Failed to build ${project} with gradle." ; exit 1 ; fi
rc=$?
check_exit_code $rc "Failed to build ${project} with gradle."
}

function displayCouchDbCodeCoverage {
Expand All @@ -196,8 +207,32 @@ function displayCouchDbCodeCoverage {
info "See html report here: file://${BASEDIR}/galasa-extensions-parent/dev.galasa.ras.couchdb/build/jacocoHtml/index.html"
}

function check_secrets {
h2 "updating secrets baseline"
cd ${BASEDIR}
detect-secrets scan --update .secrets.baseline
rc=$?
check_exit_code $rc "Failed to run detect-secrets. Please check it is installed properly"
success "updated secrets file"

h2 "running audit for secrets"
detect-secrets audit .secrets.baseline
rc=$?
check_exit_code $rc "Failed to audit detect-secrets."

#Check all secrets have been audited
secrets=$(grep -c hashed_secret .secrets.baseline)
audits=$(grep -c is_secret .secrets.baseline)
if [[ "$secrets" != "$audits" ]]; then
error "Not all secrets found have been audited"
exit 1
fi
success "secrets audit complete"
}

clean_maven_repo
build_with_gradle
displayCouchDbCodeCoverage
check_secrets

success "Project ${project} built - OK - log is at ${log_file}"

0 comments on commit caf4920

Please sign in to comment.