-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeforge.sh
More file actions
executable file
·100 lines (84 loc) · 2.06 KB
/
Copy pathcodeforge.sh
File metadata and controls
executable file
·100 lines (84 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
# apply common functions
source "$(pwd)"/src/scripts/utils.sh >/dev/null
# apply deps functions
source "$(pwd)"/src/scripts/java_deps.sh >/dev/null
# apply tools functions
source "$(pwd)"/src/scripts/scan_tools.sh >/dev/null
# apply variables functions
source "$(pwd)"/src/scripts/variables.sh >/dev/null
# apply func_complete functions
source "$(pwd)"/src/scripts/func_complete.sh >/dev/null
#
# Handle analyze command
analyze_command() {
local option="$1"
case "$option" in
mvn-dep-list)
analyze_mvn_dep_list "${POM_FILE_PATH}" "${TARGET_DIR_PATH}"
;;
mvn-dep-update)
analyze_mvn_dep_update "${POM_FILE_PATH}" "${TARGET_DIR_PATH}"
;;
mvn-dep-bom)
mvn_dep_bom "${POM_FILE_PATH}" "$(pwd)/target/deps/bom"
;;
mvn-dep-tree)
mvn_dep_tree "${POM_FILE_PATH}" "$(pwd)/target/deps/"
;;
gradle-deps)
gradle_deps "${GRADLE_FILE_PATH}" "${TARGET_DIR_PATH}"
;;
*)
echo "Invalid option: $option"
display_help
;;
esac
}
# Handle scan command
scan_command() {
local tool="$1"
case "$tool" in
snyk)
scan_with_snyk "${POM_FILE_PATH}" "${SNYK_TOKEN}" "$(pwd)/target/reports/"
;;
owasp)
scan_with_owasp "${POM_FILE_PATH}" "${TARGET_DIR_PATH}" "${OWASP_OUT_FORMAT}"
;;
blackduck)
scan_with_blackduck
;;
*)
echo "$UNKNOWN_MSG: $tool"
display_help
;;
esac
}
# Main function to handle commands
main() {
local command="$1"
# Register auto-completion function
complete -F complete_command "$command"
shift
case "$command" in
--analyze | -a)
analyze_command "$@"
;;
--scan | -s)
scan_command "$@"
;;
--help | -h)
display_help "$@"
;;
*)
log "ERROR" "$UNKNOWN_MSG $command"
display_help
;;
esac
}
# Check if the correct number of arguments is provided
if [ "$#" -lt 1 ]; then
display_help
fi
# Call the main function with provided arguments
main "$@"