@freshworks/shiftleft-tools 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +351 -0
- package/bin/shiftleft.js +95 -0
- package/package.json +57 -0
- package/src/commands/doctor.js +208 -0
- package/src/commands/init-postman.js +298 -0
- package/src/commands/init-rules.js +78 -0
- package/src/commands/link.js +172 -0
- package/src/commands/protect.js +61 -0
- package/src/commands/run-tests.js +182 -0
- package/src/commands/setup-pipeline.js +209 -0
- package/src/commands/update.js +203 -0
- package/src/index.js +4 -0
- package/src/utils/copy-tree.js +98 -0
- package/src/utils/gitignore.js +26 -0
- package/src/utils/logger.js +9 -0
- package/src/utils/manifest.js +145 -0
- package/src/utils/stack.js +80 -0
- package/src/utils/template.js +135 -0
- package/templates/AGENTS.md +109 -0
- package/templates/CLAUDE.md +3 -0
- package/templates/jenkins/Jenkinsfile-java.groovy +432 -0
- package/templates/jenkins/Jenkinsfile-node.groovy +450 -0
- package/templates/postman/.husky/pre-commit +19 -0
- package/templates/postman/.prettierrc.json +5 -0
- package/templates/postman/README.md.ejs +147 -0
- package/templates/postman/collections/01-core.json.ejs +91 -0
- package/templates/postman/config/local.json.ejs +12 -0
- package/templates/postman/config/staging.json.ejs +26 -0
- package/templates/postman/environments/local.postman_environment.json.ejs +31 -0
- package/templates/postman/environments/staging.postman_environment.json.ejs +31 -0
- package/templates/postman/gitignore +16 -0
- package/templates/postman/npmrc +31 -0
- package/templates/postman/package.json.ejs +66 -0
- package/templates/postman/run-all-shim.sh +16 -0
- package/templates/postman/scripts/auth/generate-jwt.sh +113 -0
- package/templates/postman/scripts/auth/get-issuer-secret.sh +140 -0
- package/templates/postman/scripts/infra/start-mocks.sh +138 -0
- package/templates/postman/scripts/infra/stop-mocks.sh +43 -0
- package/templates/postman/scripts/lib/api_coverage.py +1122 -0
- package/templates/postman/scripts/lib/cleanup-reports.sh +101 -0
- package/templates/postman/scripts/lib/cleanup-stryker.sh +44 -0
- package/templates/postman/scripts/lib/report_combined.py +527 -0
- package/templates/postman/scripts/lib/report_consolidated.py +363 -0
- package/templates/postman/scripts/lib/report_generator.py +121 -0
- package/templates/postman/scripts/lib/report_migration.py +156 -0
- package/templates/postman/scripts/lib/report_mutation.py +110 -0
- package/templates/postman/scripts/lib/report_unit.py +353 -0
- package/templates/postman/scripts/lib/report_utils.py +973 -0
- package/templates/postman/scripts/report-generators/generate-consolidated-report.sh +445 -0
- package/templates/postman/scripts/report-generators/java-api-coverage-matrix.sh +257 -0
- package/templates/postman/scripts/report-generators/mutation-report.sh +672 -0
- package/templates/postman/scripts/report-generators/node-api-coverage-matrix.sh +167 -0
- package/templates/postman/scripts/report-generators/stage-report-artifacts.sh +27 -0
- package/templates/postman/scripts/run-all.sh +452 -0
- package/templates/postman/scripts/runners/run-mutation-tests.sh +113 -0
- package/templates/postman/scripts/runners/run-tests-local.sh +936 -0
- package/templates/postman/scripts/runners/run-tests-staging.sh +741 -0
- package/templates/postman-node/README.md.ejs +26 -0
- package/templates/postman-node/collections/crud/01-bootstrap.json.ejs +34 -0
- package/templates/postman-node/config/local.json.ejs +46 -0
- package/templates/postman-node/config/staging.json.ejs +31 -0
- package/templates/postman-node/local.test.env.ejs +3 -0
- package/templates/postman-node/mocks/external.js +14 -0
- package/templates/postman-node/package.json.ejs +39 -0
- package/templates/postman-node/requirements.txt +1 -0
- package/templates/postman-node/scripts/database/cleanup-mysql.sh +12 -0
- package/templates/postman-node/scripts/database/run-migrations.js +29 -0
- package/templates/postman-node/scripts/database/start-mysql.sh +34 -0
- package/templates/postman-node/scripts/database/wait-for-mysql.sh +36 -0
- package/templates/postman-node/scripts/lib/api_coverage_node.py +1137 -0
- package/templates/postman-node/scripts/lib/fetch-jwt.sh +86 -0
- package/templates/postman-node/scripts/lib/run-newman.sh +104 -0
- package/templates/postman-node/scripts/lib/setup-database.sh +55 -0
- package/templates/postman-node/scripts/lib/start-app.sh +48 -0
- package/templates/postman-node/scripts/lib/utils.sh +114 -0
- package/templates/postman-node/scripts/report-generators/stage-report-artifacts.sh +26 -0
- package/templates/postman-node/scripts/run-all.sh +303 -0
- package/templates/postman-node/scripts/runners/run-tests.sh +123 -0
- package/templates/postman-node/scripts/setup-mocks.js.ejs +29 -0
- package/templates/postman-node/stryker.config.js.ejs +51 -0
- package/templates/rules/local-test-setup.mdc +420 -0
- package/templates/rules/testing-node.mdc +66 -0
- package/templates/rules/testing.mdc +248 -0
- package/templates/skills/_shared/postman-standards.md +380 -0
- package/templates/skills/enhance-test-pipeline/SKILL-java.md +483 -0
- package/templates/skills/enhance-test-pipeline/SKILL-node.md +431 -0
- package/templates/skills/enhance-test-pipeline/SKILL.md +9 -0
- package/templates/skills/review-test-suite/SKILL-java.md +137 -0
- package/templates/skills/review-test-suite/SKILL-node.md +78 -0
- package/templates/skills/review-test-suite/SKILL.md +9 -0
- package/templates/skills/run-test-suite/SKILL-java.md +186 -0
- package/templates/skills/run-test-suite/SKILL-node.md +191 -0
- package/templates/skills/run-test-suite/SKILL.md +9 -0
- package/templates/skills/setup-api-tests/SKILL-java.md +1094 -0
- package/templates/skills/setup-api-tests/SKILL-node.md +141 -0
- package/templates/skills/setup-api-tests/SKILL.md +9 -0
- package/templates/skills/setup-mutation-tests/SKILL-java.md +303 -0
- package/templates/skills/setup-mutation-tests/SKILL-node.md +408 -0
- package/templates/skills/setup-mutation-tests/SKILL.md +9 -0
- package/templates/skills/setup-test-pipeline/SKILL-java.md +454 -0
- package/templates/skills/setup-test-pipeline/SKILL-node.md +318 -0
- package/templates/skills/setup-test-pipeline/SKILL.md +9 -0
- package/templates/skills/write-api-tests/SKILL-java.md +115 -0
- package/templates/skills/write-api-tests/SKILL-node.md +83 -0
- package/templates/skills/write-api-tests/SKILL.md +9 -0
- package/templates/stryker.config.js +50 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Mock Services Setup Script
|
|
4
|
+
# Starts WireMock to mock external services (FreshID, etc.) for Postman tests
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
# Colors
|
|
9
|
+
GREEN='\033[0;32m'
|
|
10
|
+
YELLOW='\033[1;33m'
|
|
11
|
+
BLUE='\033[0;34m'
|
|
12
|
+
NC='\033[0m'
|
|
13
|
+
|
|
14
|
+
echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}"
|
|
15
|
+
echo -e "${BLUE}║ Mock Services Setup ║${NC}"
|
|
16
|
+
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}"
|
|
17
|
+
echo ""
|
|
18
|
+
|
|
19
|
+
# Configuration
|
|
20
|
+
WIREMOCK_VERSION="3.3.1"
|
|
21
|
+
WIREMOCK_PORT="${WIREMOCK_PORT:-9999}"
|
|
22
|
+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
23
|
+
WIREMOCK_DIR="$SCRIPT_DIR/wiremock"
|
|
24
|
+
MAPPINGS_DIR="$WIREMOCK_DIR/mappings"
|
|
25
|
+
FILES_DIR="$WIREMOCK_DIR/__files"
|
|
26
|
+
|
|
27
|
+
# Create directories
|
|
28
|
+
mkdir -p "$MAPPINGS_DIR"
|
|
29
|
+
mkdir -p "$FILES_DIR"
|
|
30
|
+
|
|
31
|
+
# Download WireMock if not exists
|
|
32
|
+
if [ ! -f "$WIREMOCK_DIR/wiremock-standalone.jar" ]; then
|
|
33
|
+
echo -e "${YELLOW}Downloading WireMock...${NC}"
|
|
34
|
+
curl -L "https://repo1.maven.org/maven2/org/wiremock/wiremock-standalone/$WIREMOCK_VERSION/wiremock-standalone-$WIREMOCK_VERSION.jar" \
|
|
35
|
+
-o "$WIREMOCK_DIR/wiremock-standalone.jar"
|
|
36
|
+
echo -e "${GREEN}✓ WireMock downloaded${NC}"
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
# Create FreshID OAuth App mock
|
|
40
|
+
cat > "$MAPPINGS_DIR/freshid-oauth-app.json" << 'EOF'
|
|
41
|
+
{
|
|
42
|
+
"request": {
|
|
43
|
+
"method": "GET",
|
|
44
|
+
"urlPathPattern": "/api/v2/oauth/apps/.*"
|
|
45
|
+
},
|
|
46
|
+
"response": {
|
|
47
|
+
"status": 200,
|
|
48
|
+
"headers": {
|
|
49
|
+
"Content-Type": "application/json"
|
|
50
|
+
},
|
|
51
|
+
"jsonBody": {
|
|
52
|
+
"client_id": "mock-client-id",
|
|
53
|
+
"client_secret": "mock-client-secret",
|
|
54
|
+
"description": "Mock OAuth App from WireMock",
|
|
55
|
+
"redirect_uri": ["https://mock.example.com/callback"],
|
|
56
|
+
"scopes": ["read", "write", "admin"]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
EOF
|
|
61
|
+
|
|
62
|
+
# Create encryption/decryption mock responses
|
|
63
|
+
cat > "$MAPPINGS_DIR/crypto-decrypt.json" << 'EOF'
|
|
64
|
+
{
|
|
65
|
+
"request": {
|
|
66
|
+
"method": "POST",
|
|
67
|
+
"urlPathPattern": "/api/crypto/decrypt"
|
|
68
|
+
},
|
|
69
|
+
"response": {
|
|
70
|
+
"status": 200,
|
|
71
|
+
"headers": {
|
|
72
|
+
"Content-Type": "application/json"
|
|
73
|
+
},
|
|
74
|
+
"jsonBody": {
|
|
75
|
+
"decrypted_value": {
|
|
76
|
+
"key": "mockDecryptedValue",
|
|
77
|
+
"anotherKey": "mockValue123"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
EOF
|
|
83
|
+
|
|
84
|
+
echo -e "${GREEN}✓ Mock mappings created${NC}"
|
|
85
|
+
echo ""
|
|
86
|
+
|
|
87
|
+
# Check if WireMock is already running
|
|
88
|
+
if lsof -Pi :$WIREMOCK_PORT -sTCP:LISTEN -t >/dev/null 2>&1 ; then
|
|
89
|
+
echo -e "${YELLOW}WireMock already running on port $WIREMOCK_PORT${NC}"
|
|
90
|
+
echo -e "${YELLOW}Stopping existing instance...${NC}"
|
|
91
|
+
kill $(lsof -t -i:$WIREMOCK_PORT) 2>/dev/null || true
|
|
92
|
+
sleep 2
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
# Start WireMock in background
|
|
96
|
+
echo -e "${YELLOW}Starting WireMock on port $WIREMOCK_PORT...${NC}"
|
|
97
|
+
java -jar "$WIREMOCK_DIR/wiremock-standalone.jar" \
|
|
98
|
+
--port $WIREMOCK_PORT \
|
|
99
|
+
--root-dir "$WIREMOCK_DIR" \
|
|
100
|
+
--verbose \
|
|
101
|
+
> "$WIREMOCK_DIR/wiremock.log" 2>&1 &
|
|
102
|
+
|
|
103
|
+
WIREMOCK_PID=$!
|
|
104
|
+
echo $WIREMOCK_PID > "$WIREMOCK_DIR/wiremock.pid"
|
|
105
|
+
|
|
106
|
+
# Wait for WireMock to start (using built-in __admin endpoint)
|
|
107
|
+
echo -e "${YELLOW}Waiting for WireMock to start...${NC}"
|
|
108
|
+
for i in {1..30}; do
|
|
109
|
+
if curl -s "http://localhost:$WIREMOCK_PORT/__admin" > /dev/null 2>&1; then
|
|
110
|
+
echo -e "${GREEN}✓ WireMock started successfully (PID: $WIREMOCK_PID)${NC}"
|
|
111
|
+
break
|
|
112
|
+
fi
|
|
113
|
+
sleep 1
|
|
114
|
+
done
|
|
115
|
+
|
|
116
|
+
# Final verification that WireMock is running
|
|
117
|
+
if ! curl -s "http://localhost:$WIREMOCK_PORT/__admin" > /dev/null 2>&1; then
|
|
118
|
+
echo -e "${RED}✗ Failed to start WireMock${NC}"
|
|
119
|
+
echo -e "${YELLOW}Check log file: $WIREMOCK_DIR/wiremock.log${NC}"
|
|
120
|
+
cat "$WIREMOCK_DIR/wiremock.log"
|
|
121
|
+
exit 1
|
|
122
|
+
fi
|
|
123
|
+
|
|
124
|
+
echo ""
|
|
125
|
+
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
126
|
+
echo -e "${GREEN}✓ Mock services ready!${NC}"
|
|
127
|
+
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
128
|
+
echo ""
|
|
129
|
+
echo -e "${GREEN}WireMock Admin UI:${NC} http://localhost:$WIREMOCK_PORT/__admin"
|
|
130
|
+
echo -e "${GREEN}Mock Endpoints:${NC}"
|
|
131
|
+
echo -e " - GET http://localhost:$WIREMOCK_PORT/api/v2/oauth/apps/*"
|
|
132
|
+
echo -e " - POST http://localhost:$WIREMOCK_PORT/api/crypto/decrypt"
|
|
133
|
+
echo ""
|
|
134
|
+
echo -e "${YELLOW}To stop WireMock:${NC} ./stop-mocks.sh"
|
|
135
|
+
echo ""
|
|
136
|
+
|
|
137
|
+
exit 0
|
|
138
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Stop Mock Services Script
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
# Colors
|
|
8
|
+
GREEN='\033[0;32m'
|
|
9
|
+
RED='\033[0;31m'
|
|
10
|
+
YELLOW='\033[1;33m'
|
|
11
|
+
NC='\033[0m'
|
|
12
|
+
|
|
13
|
+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
14
|
+
WIREMOCK_DIR="$SCRIPT_DIR/wiremock"
|
|
15
|
+
WIREMOCK_PORT="${WIREMOCK_PORT:-9999}"
|
|
16
|
+
|
|
17
|
+
echo -e "${YELLOW}Stopping mock services...${NC}"
|
|
18
|
+
|
|
19
|
+
# Stop WireMock
|
|
20
|
+
if [ -f "$WIREMOCK_DIR/wiremock.pid" ]; then
|
|
21
|
+
WIREMOCK_PID=$(cat "$WIREMOCK_DIR/wiremock.pid")
|
|
22
|
+
if ps -p $WIREMOCK_PID > /dev/null 2>&1; then
|
|
23
|
+
echo -e "${YELLOW}Stopping WireMock (PID: $WIREMOCK_PID)...${NC}"
|
|
24
|
+
kill $WIREMOCK_PID
|
|
25
|
+
rm -f "$WIREMOCK_DIR/wiremock.pid"
|
|
26
|
+
echo -e "${GREEN}✓ WireMock stopped${NC}"
|
|
27
|
+
else
|
|
28
|
+
echo -e "${YELLOW}WireMock not running${NC}"
|
|
29
|
+
rm -f "$WIREMOCK_DIR/wiremock.pid"
|
|
30
|
+
fi
|
|
31
|
+
else
|
|
32
|
+
# Try to find and kill by port
|
|
33
|
+
if lsof -Pi :$WIREMOCK_PORT -sTCP:LISTEN -t >/dev/null 2>&1; then
|
|
34
|
+
echo -e "${YELLOW}Stopping WireMock on port $WIREMOCK_PORT...${NC}"
|
|
35
|
+
kill $(lsof -t -i:$WIREMOCK_PORT) 2>/dev/null || true
|
|
36
|
+
echo -e "${GREEN}✓ WireMock stopped${NC}"
|
|
37
|
+
else
|
|
38
|
+
echo -e "${YELLOW}WireMock not running${NC}"
|
|
39
|
+
fi
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
echo -e "${GREEN}✓ All mock services stopped${NC}"
|
|
43
|
+
|