Skip to content

sanity-update #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
20dde54
Test Commit 1
cs-raj Apr 17, 2025
bf69d8d
Script Update
cs-raj Apr 17, 2025
b6045d8
Test Commit
cs-raj Apr 17, 2025
de39ff3
Script updated
cs-raj Apr 17, 2025
8b82e9c
updated api test cases
harshithad0703 Sep 18, 2024
37e6719
updated test cases to run sanity
harshithad0703 Oct 23, 2024
4410064
added slack channel integration for sanity reports
harshithad0703 Oct 23, 2024
d49939d
update sanity test cases
harshithad0703 Apr 23, 2025
8adf784
update sanity test cases
harshithad0703 Apr 23, 2025
e76d7c4
chore: testing slack notification for sanity report
AniketDev7 Apr 9, 2025
0dd3619
add Slack integration for sending sanity report notifications
harshithad0703 Apr 9, 2025
8276729
chore: message updated
AniketDev7 Apr 9, 2025
afbc10e
chore: updated the report url
AniketDev7 Apr 9, 2025
5964707
updated slack notif title for TS SDK
AniketDev7 Apr 10, 2025
2c737ca
chore: updated slack notif
AniketDev7 Apr 10, 2025
2767a78
Merge pull request #174 from contentstack/staging
harshithad0703 Apr 23, 2025
d7c2094
Merge branch 'development' into fix/sanity-test-cases
harshithad0703 Apr 23, 2025
024e368
fix: simplify sanity report test script
harshithad0703 Apr 23, 2025
67bf8f1
fix: standardize encoding in file read operations and update test ass…
harshithad0703 Apr 23, 2025
da958e3
Merge pull request #175 from contentstack/fix/sanity-test-cases
harshithad0703 Apr 23, 2025
d803048
Merge branch 'development' into fix/Snyk
harshithad0703 Apr 23, 2025
6e40987
Merge pull request #166 from contentstack/fix/Snyk
harshithad0703 Apr 23, 2025
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: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ tap-html.html
coverage
.env
.dccache
dist/*
dist/*
*.log
69 changes: 69 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env sh
# Pre-commit hook to run Snyk and Talisman scans, completing both before deciding to commit

# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Check if Snyk is installed
if ! command_exists snyk; then
echo "Error: Snyk is not installed. Please install it and try again."
exit 1
fi

# Check if Talisman is installed
if ! command_exists talisman; then
echo "Error: Talisman is not installed. Please install it and try again."
exit 1
fi

# Allow bypassing the hook with an environment variable
if [ "$SKIP_HOOK" = "1" ]; then
echo "Skipping Snyk and Talisman scans (SKIP_HOOK=1)."
exit 0
fi

# Initialize variables to track scan results
snyk_failed=false
talisman_failed=false

# Run Snyk vulnerability scan
echo "Running Snyk vulnerability scan..."
snyk test --all-projects > snyk_output.log 2>&1
snyk_exit_code=$?

if [ $snyk_exit_code -eq 0 ]; then
echo "Snyk scan passed: No vulnerabilities found."
elif [ $snyk_exit_code -eq 1 ]; then
echo "Snyk found vulnerabilities. See snyk_output.log for details."
snyk_failed=true
else
echo "Snyk scan failed with error (exit code $snyk_exit_code). See snyk_output.log for details."
snyk_failed=true
fi

# Run Talisman secret scan (continues even if Snyk failed)
echo "Running Talisman secret scan..."
talisman --githook pre-commit > talisman_output.log 2>&1
talisman_exit_code=$?

if [ $talisman_exit_code -eq 0 ]; then
echo "Talisman scan passed: No secrets found."
else
echo "Talisman scan failed (exit code $talisman_exit_code). See talisman_output.log for details."
talisman_failed=true
fi

# Evaluate results after both scans
if [ "$snyk_failed" = true ] || [ "$talisman_failed" = true ]; then
echo "Commit aborted due to issues found in one or both scans."
[ "$snyk_failed" = true ] && echo "- Snyk issues: Check snyk_output.log"
[ "$talisman_failed" = true ] && echo "- Talisman issues: Check talisman_output.log"
exit 1
fi

# If both scans pass, allow the commit
echo "All scans passed. Proceeding with commit.cd ."
rm -f snyk_output.log talisman_output.log
exit 0
22 changes: 12 additions & 10 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
fileignoreconfig:
- filename: package-lock.json
checksum: ffe61fb2806dc761b2f8e560b3d27aa58ae2fe2bdf5a48f68d80ee0fb74ffdb6
- filename: src/lib/types.ts
checksum: 1eb6d6ec971934d65017dae2f82d6d6ef1cd0e6bfd50f43a9b46f30182307230
- filename: test/unit/image-transform.spec.ts
checksum: 7beabdd07bd35d620668fcd97e1a303b9cbc40170bf3008a376d75ce0895de2a
- filename: test/utils/mocks.ts
checksum: a1cb4b1890a584f1facd30f2a0974c97a66f91417022be79d00516338e244227
- filename: src/lib/query.ts
checksum: c4529069bc974d15c104303c5ae573c9341185a869c612ab07f0ee7f42e8b149
- filename: src/lib/types.ts
checksum: 1eb6d6ec971934d65017dae2f82d6d6ef1cd0e6bfd50f43a9b46f30182307230
- filename: test/unit/image-transform.spec.ts
checksum: 7beabdd07bd35d620668fcd97e1a303b9cbc40170bf3008a376d75ce0895de2a
- filename: test/utils/mocks.ts
checksum: a1cb4b1890a584f1facd30f2a0974c97a66f91417022be79d00516338e244227
- filename: src/lib/query.ts
checksum: c4529069bc974d15c104303c5ae573c9341185a869c612ab07f0ee7f42e8b149
- filename: package-lock.json
checksum: 785542a3fd3925cf6d6067b78580a93519e2fd4f552b0edf747aace573f4a372
- filename: .husky/pre-commit
checksum: 5baabd7d2c391648163f9371f0e5e9484f8fb90fa2284cfc378732ec3192c193
version: ""
57 changes: 31 additions & 26 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,54 @@
/* eslint-disable */
export default {
testEnvironment: 'jsdom',
displayName: 'contentstack-delivery',
preset: './jest.preset.js',
transform: {
'^.+\\.[tj]s$': ['ts-jest', {
tsconfig: '<rootDir>/tsconfig.spec.json',
}],
"^.+\\.[tj]s$": [
"ts-jest",
{
tsconfig: "<rootDir>/tsconfig.spec.json",
},
],
},
moduleFileExtensions: ['ts', 'js', 'html'],
moduleFileExtensions: ["ts", "js", "html"],
collectCoverage: true,
coverageDirectory: './reports/contentstack-delivery/coverage/',
collectCoverageFrom: [
"src/**",
"!src/index.ts"
],
coverageDirectory: "./reports/contentstack-delivery/coverage/",
collectCoverageFrom: ["src/**", "!src/index.ts"],
coverageThreshold: {
// global: {
// branches: 95,
// functions: 95,
// lines: 95,
// statements: 95
// }
},
reporters: [
'default',
"default",
[
"jest-html-reporter",
{
pageTitle: "API Test Report",
outputPath: "reports/sanity.html",
includeFailureMsg: true,
includeConsoleLog: true,
},
],
[
'jest-html-reporters',
"jest-html-reporters",
{
publicPath: './reports/contentstack-delivery/html',
filename: 'index.html',
publicPath: "./reports/contentstack-delivery/html",
filename: "index.html",
expand: true,
},
],
[
'jest-junit',
"jest-junit",
{
outputDirectory: 'reports/contentstack-delivery/junit',
outputName: 'jest-junit.xml',
ancestorSeparator: '',
uniqueOutputName: 'false',
suiteNameTemplate: '{filepath}',
classNameTemplate: '{classname}',
titleTemplate: '{title}',
outputDirectory: "reports/contentstack-delivery/junit",
outputName: "jest-junit.xml",
ancestorSeparator: "",
uniqueOutputName: "false",
suiteNameTemplate: "{filepath}",
classNameTemplate: "{classname}",
titleTemplate: "{title}",
},
],
],
};
};
Loading
Loading