Skip to content

Commit 5d49987

Browse files
2 parents e94ab45 + 2e8aaeb commit 5d49987

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

docs/ORCHESTRATION.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
### orchestrators
2+
3+
for now we have 2 orchestrators :
4+
- docker-compose.dast.yml : orchestrating app with zap assuming no db is needed for the app
5+
- docker-compose.java17mvn3.9.yml : orchestrates for app with db , works for test and smoke if db is required but does not have zap service
6+
7+
what should be implemented is either one global compose with a way to disable services using preexisting images as disablers that just exit with 0 and add condition to only depend on db if its a non dummy service . or to have the backend use the service blocks to generate a docker compose each time , sort of proceduraly based on user input and core engine logic .
8+
9+
same logic may be applied later to add frontend support as well .
10+
11+
12+
### pro mode
13+
14+
allowing users to run anything with 0 restrictions is dangerous on the host , the approach well go for is allowing change of the core command of each stage with a exit status management , like this :
15+
```bash
16+
: "${TOOL_CMD:=gitleaks dir \"$APP_DIR\" --report-format json --report-path \"$LOG_FILE\"}"
17+
18+
START_TS=$(date +%s%3N)
19+
20+
eval "$TOOL_CMD"
21+
EXIT_CODE=$?
22+
23+
# -------------------------------
24+
# Standardized exit code handling
25+
# -------------------------------
26+
case $EXIT_CODE in
27+
0) STATUS="SUCCESS"; MESSAGE="no leaks found" ;;
28+
1) STATUS="FAILURE"; MESSAGE="leaks found, see $LOG_FILE for details" ;;
29+
2) STATUS="ERROR"; MESSAGE="tool error" ;;
30+
*) STATUS="UNKNOWN"; MESSAGE="unknown exit code $EXIT_CODE" ;;
31+
esac
32+
```
33+
another thing needed is dependencies in the runner , the template potentiallywould be shown to the user and they input jistwhat to be added to it not full modification (to avoid users not using a non root user ...) then they would wait for the image to be built , wont be pushed to dockerhub , since its custum its also going to be deleted by the end , then if its built their custum script is ran and reports are generated and given , this keeps the host safr while allowing a fair amount of custumization .
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
set -Eeuo pipefail
3+
4+
REPORTS_DIR="${REPORTS_DIR:-../reports}"
5+
APP_DIR="${APP_DIR:-../source}"
6+
STAGE="secrets-dir"
7+
REPORT_DIR="${REPORTS_DIR}/${STAGE}"
8+
REPORT_FILE="${REPORT_DIR}/result.json"
9+
LOG_FILE="${REPORT_DIR}/${STAGE}.json"
10+
11+
mkdir -p "${REPORT_DIR}"
12+
13+
# -------------------------------
14+
# Core command (user can override)
15+
# -------------------------------
16+
: "${TOOL_CMD:=gitleaks dir \"$APP_DIR\" --report-format json --report-path \"$LOG_FILE\"}"
17+
18+
START_TS=$(date +%s%3N)
19+
20+
eval "$TOOL_CMD"
21+
EXIT_CODE=$?
22+
23+
# -------------------------------
24+
# Standardized exit code handling
25+
# -------------------------------
26+
case $EXIT_CODE in
27+
0) STATUS="SUCCESS"; MESSAGE="no leaks found" ;;
28+
1) STATUS="FAILURE"; MESSAGE="leaks found, see $LOG_FILE for details" ;;
29+
2) STATUS="ERROR"; MESSAGE="tool error" ;;
30+
*) STATUS="UNKNOWN"; MESSAGE="unknown exit code $EXIT_CODE" ;;
31+
esac
32+
33+
END_TS=$(date +%s%3N)
34+
DURATION=$((END_TS - START_TS))
35+
36+
cat > "${REPORT_FILE}" <<EOF
37+
{
38+
"stage": "${STAGE}",
39+
"status": "${STATUS}",
40+
"duration_ms": ${DURATION},
41+
"message": "${MESSAGE}"
42+
}
43+
EOF
44+
45+
exit $EXIT_CODE

0 commit comments

Comments
 (0)