Skip to content

Commit 05122b1

Browse files
authored
Merge pull request #172 from contentstack/staging
DX | 28-04-2025 | Release
2 parents 55c5eb8 + cdb247d commit 05122b1

25 files changed

+2247
-1094
lines changed

.github/workflows/policy-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ jobs:
4343
if [ "$license_file_found" = false ]; then
4444
echo "No license file found. Please add a license file to the repository."
4545
exit 1
46-
fi
46+
fi

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ tap-html.html
1212
coverage
1313
.env
1414
.dccache
15-
dist/*
15+
dist/*
16+
*.log

.husky/pre-commit

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env sh
2+
# Pre-commit hook to run Snyk and Talisman scans, completing both before deciding to commit
3+
4+
# Function to check if a command exists
5+
command_exists() {
6+
command -v "$1" >/dev/null 2>&1
7+
}
8+
9+
# Check if Snyk is installed
10+
if ! command_exists snyk; then
11+
echo "Error: Snyk is not installed. Please install it and try again."
12+
exit 1
13+
fi
14+
15+
# Check if Talisman is installed
16+
if ! command_exists talisman; then
17+
echo "Error: Talisman is not installed. Please install it and try again."
18+
exit 1
19+
fi
20+
21+
# Allow bypassing the hook with an environment variable
22+
if [ "$SKIP_HOOK" = "1" ]; then
23+
echo "Skipping Snyk and Talisman scans (SKIP_HOOK=1)."
24+
exit 0
25+
fi
26+
27+
# Initialize variables to track scan results
28+
snyk_failed=false
29+
talisman_failed=false
30+
31+
# Run Snyk vulnerability scan
32+
echo "Running Snyk vulnerability scan..."
33+
snyk test --all-projects > snyk_output.log 2>&1
34+
snyk_exit_code=$?
35+
36+
if [ $snyk_exit_code -eq 0 ]; then
37+
echo "Snyk scan passed: No vulnerabilities found."
38+
elif [ $snyk_exit_code -eq 1 ]; then
39+
echo "Snyk found vulnerabilities. See snyk_output.log for details."
40+
snyk_failed=true
41+
else
42+
echo "Snyk scan failed with error (exit code $snyk_exit_code). See snyk_output.log for details."
43+
snyk_failed=true
44+
fi
45+
46+
# Run Talisman secret scan (continues even if Snyk failed)
47+
echo "Running Talisman secret scan..."
48+
talisman --githook pre-commit > talisman_output.log 2>&1
49+
talisman_exit_code=$?
50+
51+
if [ $talisman_exit_code -eq 0 ]; then
52+
echo "Talisman scan passed: No secrets found."
53+
else
54+
echo "Talisman scan failed (exit code $talisman_exit_code). See talisman_output.log for details."
55+
talisman_failed=true
56+
fi
57+
58+
# Evaluate results after both scans
59+
if [ "$snyk_failed" = true ] || [ "$talisman_failed" = true ]; then
60+
echo "Commit aborted due to issues found in one or both scans."
61+
[ "$snyk_failed" = true ] && echo "- Snyk issues: Check snyk_output.log"
62+
[ "$talisman_failed" = true ] && echo "- Talisman issues: Check talisman_output.log"
63+
exit 1
64+
fi
65+
66+
# If both scans pass, allow the commit
67+
echo "All scans passed. Proceeding with commit.cd ."
68+
rm -f snyk_output.log talisman_output.log
69+
exit 0

.talismanrc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
fileignoreconfig:
2-
- filename: package-lock.json
3-
checksum: ffe61fb2806dc761b2f8e560b3d27aa58ae2fe2bdf5a48f68d80ee0fb74ffdb6
4-
- filename: src/lib/types.ts
5-
checksum: 1eb6d6ec971934d65017dae2f82d6d6ef1cd0e6bfd50f43a9b46f30182307230
6-
- filename: test/unit/image-transform.spec.ts
7-
checksum: 7beabdd07bd35d620668fcd97e1a303b9cbc40170bf3008a376d75ce0895de2a
8-
- filename: test/utils/mocks.ts
9-
checksum: a1cb4b1890a584f1facd30f2a0974c97a66f91417022be79d00516338e244227
10-
- filename: src/lib/query.ts
11-
checksum: c4529069bc974d15c104303c5ae573c9341185a869c612ab07f0ee7f42e8b149
2+
- filename: src/lib/types.ts
3+
checksum: 1eb6d6ec971934d65017dae2f82d6d6ef1cd0e6bfd50f43a9b46f30182307230
4+
- filename: test/unit/image-transform.spec.ts
5+
checksum: 7beabdd07bd35d620668fcd97e1a303b9cbc40170bf3008a376d75ce0895de2a
6+
- filename: test/utils/mocks.ts
7+
checksum: a1cb4b1890a584f1facd30f2a0974c97a66f91417022be79d00516338e244227
8+
- filename: src/lib/query.ts
9+
checksum: c4529069bc974d15c104303c5ae573c9341185a869c612ab07f0ee7f42e8b149
10+
- filename: package-lock.json
11+
checksum: 785542a3fd3925cf6d6067b78580a93519e2fd4f552b0edf747aace573f4a372
12+
- filename: .husky/pre-commit
13+
checksum: 5baabd7d2c391648163f9371f0e5e9484f8fb90fa2284cfc378732ec3192c193
1214
version: ""

jest.config.ts

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,54 @@
11
/* eslint-disable */
22
export default {
3-
testEnvironment: 'jsdom',
43
displayName: 'contentstack-delivery',
54
preset: './jest.preset.js',
65
transform: {
7-
'^.+\\.[tj]s$': ['ts-jest', {
8-
tsconfig: '<rootDir>/tsconfig.spec.json',
9-
}],
6+
"^.+\\.[tj]s$": [
7+
"ts-jest",
8+
{
9+
tsconfig: "<rootDir>/tsconfig.spec.json",
10+
},
11+
],
1012
},
11-
moduleFileExtensions: ['ts', 'js', 'html'],
13+
moduleFileExtensions: ["ts", "js", "html"],
1214
collectCoverage: true,
13-
coverageDirectory: './reports/contentstack-delivery/coverage/',
14-
collectCoverageFrom: [
15-
"src/**",
16-
"!src/index.ts"
17-
],
15+
coverageDirectory: "./reports/contentstack-delivery/coverage/",
16+
collectCoverageFrom: ["src/**", "!src/index.ts"],
1817
coverageThreshold: {
1918
// global: {
2019
// branches: 95,
21-
// functions: 95,
22-
// lines: 95,
23-
// statements: 95
2420
// }
2521
},
2622
reporters: [
27-
'default',
23+
"default",
24+
[
25+
"jest-html-reporter",
26+
{
27+
pageTitle: "API Test Report",
28+
outputPath: "reports/sanity.html",
29+
includeFailureMsg: true,
30+
includeConsoleLog: true,
31+
},
32+
],
2833
[
29-
'jest-html-reporters',
34+
"jest-html-reporters",
3035
{
31-
publicPath: './reports/contentstack-delivery/html',
32-
filename: 'index.html',
36+
publicPath: "./reports/contentstack-delivery/html",
37+
filename: "index.html",
3338
expand: true,
3439
},
3540
],
3641
[
37-
'jest-junit',
42+
"jest-junit",
3843
{
39-
outputDirectory: 'reports/contentstack-delivery/junit',
40-
outputName: 'jest-junit.xml',
41-
ancestorSeparator: '',
42-
uniqueOutputName: 'false',
43-
suiteNameTemplate: '{filepath}',
44-
classNameTemplate: '{classname}',
45-
titleTemplate: '{title}',
44+
outputDirectory: "reports/contentstack-delivery/junit",
45+
outputName: "jest-junit.xml",
46+
ancestorSeparator: "",
47+
uniqueOutputName: "false",
48+
suiteNameTemplate: "{filepath}",
49+
classNameTemplate: "{classname}",
50+
titleTemplate: "{title}",
4651
},
4752
],
4853
],
49-
};
54+
};

0 commit comments

Comments
 (0)