Skip to content

Commit 28f4fd1

Browse files
committed
Added Docker support, setup, and uninstall scripts for CVE Scanner CLI
1 parent 3dc3a59 commit 28f4fd1

6 files changed

Lines changed: 137 additions & 3 deletions

File tree

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
myenv/
2+
__pycache__/
3+
*.pyc
4+
*.pyo
5+
*.pyd
6+
.git/
7+
.gitignore
8+
demo/

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.13-slim
2+
3+
WORKDIR /app
4+
5+
ENV PYTHONDONTWRITEBYTECODE=1 \
6+
PYTHONUNBUFFERED=1
7+
8+
COPY requirements.txt ./
9+
10+
RUN pip install --no-cache-dir --upgrade pip \
11+
&& pip install --no-cache-dir -r requirements.txt
12+
13+
COPY cve_search_cli.py ./
14+
15+
ENTRYPOINT ["python", "/app/cve_search_cli.py"]

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,43 @@ bash setup.sh
3030
```
3131
This will install all dependencies in a virtual environment and create a `cvecli` command in your `~/.local/bin` directory.
3232

33-
Make sure `~/.local/bin` is in your PATH:
33+
The setup script also adds `~/.local/bin` to your shell startup file if it is missing. If your current terminal was already open before setup, reload it with:
3434
```bash
35-
export PATH="$HOME/.local/bin:$PATH"
35+
source ~/.bashrc
36+
```
37+
38+
If you use zsh, run:
39+
40+
```bash
41+
source ~/.zshrc
42+
```
43+
44+
## Uninstall
45+
To remove the global `cvecli` command and the PATH entry added by setup, run:
46+
47+
```bash
48+
bash uninstall.sh
49+
```
50+
51+
This removes the `~/.local/bin/cvecli` launcher and cleans the PATH line from your shell startup files. It does not delete the repository folder or `myenv`.
52+
53+
## Docker Setup
54+
Build and run the CLI with Docker in one line:
55+
56+
```bash
57+
docker build -t cvecli . && docker run --rm -it cvecli
58+
```
59+
60+
Run a direct CVE lookup without entering interactive mode:
61+
62+
```bash
63+
docker build -t cvecli . && docker run --rm cvecli --id CVE-2025-55184
64+
```
65+
66+
Run a keyword search:
67+
68+
```bash
69+
docker build -t cvecli . && docker run --rm cvecli --keyword wordpress
3670
```
3771

3872
## Usage

cve_search_cli.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,8 @@ def main():
122122
interactive_menu()
123123

124124
if __name__ == "__main__":
125-
main()
125+
try:
126+
main()
127+
except KeyboardInterrupt:
128+
console.print("\n[bold yellow]Interrupted by user. Exiting.[/]")
129+
sys.exit(130)

setup.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,37 @@ chmod +x cve_search_cli.py
2525
mkdir -p "$HOME/.local/bin"
2626
ln -sf "$PWD/cve_search_cli.py" "$HOME/.local/bin/cvecli"
2727

28+
PATH_EXPORT='export PATH="$HOME/.local/bin:$PATH"'
29+
SHELL_NAME="$(basename "${SHELL:-}")"
30+
RC_FILE=""
31+
32+
case "$SHELL_NAME" in
33+
bash)
34+
if [ -f "$HOME/.bashrc" ]; then
35+
RC_FILE="$HOME/.bashrc"
36+
else
37+
RC_FILE="$HOME/.profile"
38+
fi
39+
;;
40+
zsh)
41+
RC_FILE="$HOME/.zshrc"
42+
;;
43+
*)
44+
if [ -f "$HOME/.profile" ]; then
45+
RC_FILE="$HOME/.profile"
46+
fi
47+
;;
48+
esac
49+
50+
if [ -n "$RC_FILE" ]; then
51+
touch "$RC_FILE"
52+
if ! grep -Fqx "$PATH_EXPORT" "$RC_FILE"; then
53+
printf '\n%s\n' "$PATH_EXPORT" >> "$RC_FILE"
54+
printf "\033[0;32mAdded ~/.local/bin to PATH in %s\033[0m\n" "$RC_FILE"
55+
printf "\033[0;33mOpen a new terminal or run: source %s\033[0m\n" "$RC_FILE"
56+
fi
57+
fi
58+
2859
# Print green success message
2960
printf "\033[0;32mSetup complete! Use 'cvecli' from anywhere to run the tool.\033[0m\n"
3061
printf "\033[0;32mExample: cvecli --id CVE-2025-55184\033[0m\n"

uninstall.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
CLI_LINK="$HOME/.local/bin/cvecli"
5+
PATH_EXPORT='export PATH="$HOME/.local/bin:$PATH"'
6+
REMOVED_PATH_LINE=0
7+
8+
remove_path_line() {
9+
local rc_file="$1"
10+
local temp_file
11+
12+
if [ ! -f "$rc_file" ]; then
13+
return
14+
fi
15+
16+
if ! grep -Fqx "$PATH_EXPORT" "$rc_file"; then
17+
return
18+
fi
19+
20+
temp_file="$(mktemp)"
21+
grep -Fvx "$PATH_EXPORT" "$rc_file" > "$temp_file" || true
22+
mv "$temp_file" "$rc_file"
23+
REMOVED_PATH_LINE=1
24+
printf "\033[0;32mRemoved PATH entry from %s\033[0m\n" "$rc_file"
25+
}
26+
27+
if [ -L "$CLI_LINK" ] || [ -f "$CLI_LINK" ]; then
28+
rm -f "$CLI_LINK"
29+
printf "\033[0;32mRemoved %s\033[0m\n" "$CLI_LINK"
30+
else
31+
printf "\033[0;33mNo cvecli launcher found at %s\033[0m\n" "$CLI_LINK"
32+
fi
33+
34+
remove_path_line "$HOME/.bashrc"
35+
remove_path_line "$HOME/.zshrc"
36+
remove_path_line "$HOME/.profile"
37+
38+
printf "\033[0;32mUninstall complete.\033[0m\n"
39+
40+
if [ "$REMOVED_PATH_LINE" -eq 1 ]; then
41+
printf "\033[0;33mOpen a new terminal or reload your shell config to apply the PATH change.\033[0m\n"
42+
fi

0 commit comments

Comments
 (0)