@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.
Files changed (106) hide show
  1. package/README.md +351 -0
  2. package/bin/shiftleft.js +95 -0
  3. package/package.json +57 -0
  4. package/src/commands/doctor.js +208 -0
  5. package/src/commands/init-postman.js +298 -0
  6. package/src/commands/init-rules.js +78 -0
  7. package/src/commands/link.js +172 -0
  8. package/src/commands/protect.js +61 -0
  9. package/src/commands/run-tests.js +182 -0
  10. package/src/commands/setup-pipeline.js +209 -0
  11. package/src/commands/update.js +203 -0
  12. package/src/index.js +4 -0
  13. package/src/utils/copy-tree.js +98 -0
  14. package/src/utils/gitignore.js +26 -0
  15. package/src/utils/logger.js +9 -0
  16. package/src/utils/manifest.js +145 -0
  17. package/src/utils/stack.js +80 -0
  18. package/src/utils/template.js +135 -0
  19. package/templates/AGENTS.md +109 -0
  20. package/templates/CLAUDE.md +3 -0
  21. package/templates/jenkins/Jenkinsfile-java.groovy +432 -0
  22. package/templates/jenkins/Jenkinsfile-node.groovy +450 -0
  23. package/templates/postman/.husky/pre-commit +19 -0
  24. package/templates/postman/.prettierrc.json +5 -0
  25. package/templates/postman/README.md.ejs +147 -0
  26. package/templates/postman/collections/01-core.json.ejs +91 -0
  27. package/templates/postman/config/local.json.ejs +12 -0
  28. package/templates/postman/config/staging.json.ejs +26 -0
  29. package/templates/postman/environments/local.postman_environment.json.ejs +31 -0
  30. package/templates/postman/environments/staging.postman_environment.json.ejs +31 -0
  31. package/templates/postman/gitignore +16 -0
  32. package/templates/postman/npmrc +31 -0
  33. package/templates/postman/package.json.ejs +66 -0
  34. package/templates/postman/run-all-shim.sh +16 -0
  35. package/templates/postman/scripts/auth/generate-jwt.sh +113 -0
  36. package/templates/postman/scripts/auth/get-issuer-secret.sh +140 -0
  37. package/templates/postman/scripts/infra/start-mocks.sh +138 -0
  38. package/templates/postman/scripts/infra/stop-mocks.sh +43 -0
  39. package/templates/postman/scripts/lib/api_coverage.py +1122 -0
  40. package/templates/postman/scripts/lib/cleanup-reports.sh +101 -0
  41. package/templates/postman/scripts/lib/cleanup-stryker.sh +44 -0
  42. package/templates/postman/scripts/lib/report_combined.py +527 -0
  43. package/templates/postman/scripts/lib/report_consolidated.py +363 -0
  44. package/templates/postman/scripts/lib/report_generator.py +121 -0
  45. package/templates/postman/scripts/lib/report_migration.py +156 -0
  46. package/templates/postman/scripts/lib/report_mutation.py +110 -0
  47. package/templates/postman/scripts/lib/report_unit.py +353 -0
  48. package/templates/postman/scripts/lib/report_utils.py +973 -0
  49. package/templates/postman/scripts/report-generators/generate-consolidated-report.sh +445 -0
  50. package/templates/postman/scripts/report-generators/java-api-coverage-matrix.sh +257 -0
  51. package/templates/postman/scripts/report-generators/mutation-report.sh +672 -0
  52. package/templates/postman/scripts/report-generators/node-api-coverage-matrix.sh +167 -0
  53. package/templates/postman/scripts/report-generators/stage-report-artifacts.sh +27 -0
  54. package/templates/postman/scripts/run-all.sh +452 -0
  55. package/templates/postman/scripts/runners/run-mutation-tests.sh +113 -0
  56. package/templates/postman/scripts/runners/run-tests-local.sh +936 -0
  57. package/templates/postman/scripts/runners/run-tests-staging.sh +741 -0
  58. package/templates/postman-node/README.md.ejs +26 -0
  59. package/templates/postman-node/collections/crud/01-bootstrap.json.ejs +34 -0
  60. package/templates/postman-node/config/local.json.ejs +46 -0
  61. package/templates/postman-node/config/staging.json.ejs +31 -0
  62. package/templates/postman-node/local.test.env.ejs +3 -0
  63. package/templates/postman-node/mocks/external.js +14 -0
  64. package/templates/postman-node/package.json.ejs +39 -0
  65. package/templates/postman-node/requirements.txt +1 -0
  66. package/templates/postman-node/scripts/database/cleanup-mysql.sh +12 -0
  67. package/templates/postman-node/scripts/database/run-migrations.js +29 -0
  68. package/templates/postman-node/scripts/database/start-mysql.sh +34 -0
  69. package/templates/postman-node/scripts/database/wait-for-mysql.sh +36 -0
  70. package/templates/postman-node/scripts/lib/api_coverage_node.py +1137 -0
  71. package/templates/postman-node/scripts/lib/fetch-jwt.sh +86 -0
  72. package/templates/postman-node/scripts/lib/run-newman.sh +104 -0
  73. package/templates/postman-node/scripts/lib/setup-database.sh +55 -0
  74. package/templates/postman-node/scripts/lib/start-app.sh +48 -0
  75. package/templates/postman-node/scripts/lib/utils.sh +114 -0
  76. package/templates/postman-node/scripts/report-generators/stage-report-artifacts.sh +26 -0
  77. package/templates/postman-node/scripts/run-all.sh +303 -0
  78. package/templates/postman-node/scripts/runners/run-tests.sh +123 -0
  79. package/templates/postman-node/scripts/setup-mocks.js.ejs +29 -0
  80. package/templates/postman-node/stryker.config.js.ejs +51 -0
  81. package/templates/rules/local-test-setup.mdc +420 -0
  82. package/templates/rules/testing-node.mdc +66 -0
  83. package/templates/rules/testing.mdc +248 -0
  84. package/templates/skills/_shared/postman-standards.md +380 -0
  85. package/templates/skills/enhance-test-pipeline/SKILL-java.md +483 -0
  86. package/templates/skills/enhance-test-pipeline/SKILL-node.md +431 -0
  87. package/templates/skills/enhance-test-pipeline/SKILL.md +9 -0
  88. package/templates/skills/review-test-suite/SKILL-java.md +137 -0
  89. package/templates/skills/review-test-suite/SKILL-node.md +78 -0
  90. package/templates/skills/review-test-suite/SKILL.md +9 -0
  91. package/templates/skills/run-test-suite/SKILL-java.md +186 -0
  92. package/templates/skills/run-test-suite/SKILL-node.md +191 -0
  93. package/templates/skills/run-test-suite/SKILL.md +9 -0
  94. package/templates/skills/setup-api-tests/SKILL-java.md +1094 -0
  95. package/templates/skills/setup-api-tests/SKILL-node.md +141 -0
  96. package/templates/skills/setup-api-tests/SKILL.md +9 -0
  97. package/templates/skills/setup-mutation-tests/SKILL-java.md +303 -0
  98. package/templates/skills/setup-mutation-tests/SKILL-node.md +408 -0
  99. package/templates/skills/setup-mutation-tests/SKILL.md +9 -0
  100. package/templates/skills/setup-test-pipeline/SKILL-java.md +454 -0
  101. package/templates/skills/setup-test-pipeline/SKILL-node.md +318 -0
  102. package/templates/skills/setup-test-pipeline/SKILL.md +9 -0
  103. package/templates/skills/write-api-tests/SKILL-java.md +115 -0
  104. package/templates/skills/write-api-tests/SKILL-node.md +83 -0
  105. package/templates/skills/write-api-tests/SKILL.md +9 -0
  106. 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
+