code-audit-23 0.1.1__tar.gz → 0.1.4__tar.gz

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.

Potentially problematic release.


This version of code-audit-23 might be problematic. Click here for more details.

Files changed (24) hide show
  1. {code_audit_23-0.1.1/code_audit_23.egg-info → code_audit_23-0.1.4}/PKG-INFO +9 -8
  2. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/README.md +6 -6
  3. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23/main.py +32 -16
  4. code_audit_23-0.1.4/code_audit_23/semgrep_cli.py +102 -0
  5. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23/sonarqube_cli.py +1 -1
  6. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23/trivy_cli.py +3 -0
  7. {code_audit_23-0.1.1 → code_audit_23-0.1.4/code_audit_23.egg-info}/PKG-INFO +9 -8
  8. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23.egg-info/SOURCES.txt +1 -0
  9. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23.egg-info/requires.txt +1 -0
  10. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/pyproject.toml +3 -2
  11. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/LICENSE +0 -0
  12. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/MANIFEST.in +0 -0
  13. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23/__init__.py +0 -0
  14. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23/logger.py +0 -0
  15. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23/sonar-scanner/bin/sonar-scanner +0 -0
  16. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23/sonar-scanner/bin/sonar-scanner-debug +0 -0
  17. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23/sonar-scanner/bin/sonar-scanner-debug.bat +0 -0
  18. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23/sonar-scanner/bin/sonar-scanner.bat +0 -0
  19. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23/sonar-scanner/conf/sonar-scanner.properties +0 -0
  20. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23/sonar-scanner/lib/sonar-scanner-cli-7.3.0.5189.jar +0 -0
  21. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23.egg-info/dependency_links.txt +0 -0
  22. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23.egg-info/entry_points.txt +0 -0
  23. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/code_audit_23.egg-info/top_level.txt +0 -0
  24. {code_audit_23-0.1.1 → code_audit_23-0.1.4}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: code-audit-23
3
- Version: 0.1.1
4
- Summary: A simple local scanner for code audits (Trivy, SonarQube, for Brain Station 23)
3
+ Version: 0.1.4
4
+ Summary: A simple local scanner for code audits (Trivy, Semgrep, SonarQube, for Brain Station 23)
5
5
  Author-email: Ahmad Al-Sajid <ahmad.sajid@brainstation23.com>
6
6
  License-Expression: MIT
7
7
  Requires-Python: >=3.9
@@ -10,6 +10,7 @@ License-File: LICENSE
10
10
  Requires-Dist: click<9.0,>=8.1.7
11
11
  Requires-Dist: python-dotenv<2.0,>=1.0
12
12
  Requires-Dist: requests<3.0,>=2.31
13
+ Requires-Dist: semgrep<2.0,>=1.0
13
14
  Dynamic: license-file
14
15
 
15
16
  # Code Audit 23
@@ -25,7 +26,7 @@ Code Audit 23 is a comprehensive command-line interface (CLI) tool that unifies
25
26
  - **Unified Interface**: Single command to run multiple code quality and security scans
26
27
  - **Multiple Tools Integration**:
27
28
  - **SonarQube** - Code quality and security analysis
28
- - **Gitleaks** - Detect hardcoded secrets and credentials
29
+ - **Semgrep** - Static code analysis for security issues
29
30
  - **Trivy** - Vulnerability scanning for dependencies and container images
30
31
  - **Interactive Menu**: User-friendly command-line interface
31
32
  - **Cross-Platform**: Works on Windows, macOS, and Linux
@@ -102,16 +103,16 @@ Options:
102
103
 
103
104
  ### Menu Options
104
105
 
105
- 1. **Quick Scan** - Run all security scans in sequence (SonarQube + Gitleaks + Trivy)
106
- 2. **Gitleaks Scan** - Scan for secrets and sensitive information
107
- 3. **Trivy Scan** - Scan for vulnerabilities in dependencies and container images
106
+ 1. **Quick Scan** - Run all security scans in sequence (Trivy + Semgrep + SonarQube)
107
+ 2. **Trivy Scan** - Scan for vulnerabilities in dependencies and container images
108
+ 3. **Semgrep Scan** - Static code analysis for security issues
108
109
  4. **SonarQube Scan** - Analyze code quality and security issues
109
110
 
110
111
  ## 📊 Output
111
112
 
112
113
  All scan reports are saved in the `reports/` directory in SARIF format:
113
- - `reports/gitleaks.sarif` - Results from Gitleaks scan
114
114
  - `reports/trivy.sarif` - Results from Trivy scan
115
+ - `reports/semgrep.sarif` - Results from Semgrep scan
115
116
  - SonarQube results are available on your SonarQube server
116
117
 
117
118
  ## 🧪 Development
@@ -176,7 +177,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
176
177
  ## 🙏 Acknowledgments
177
178
 
178
179
  - [SonarQube](https://www.sonarqube.org/) - For the amazing code quality platform
179
- - [Gitleaks](https://github.com/gitleaks/gitleaks) - For the secrets detection
180
+ - [Semgrep](https://semgrep.dev/) - For static code analysis
180
181
  - [Trivy](https://github.com/aquasecurity/trivy) - For the vulnerability scanning
181
182
 
182
183
  ## 📧 Contact
@@ -11,7 +11,7 @@ Code Audit 23 is a comprehensive command-line interface (CLI) tool that unifies
11
11
  - **Unified Interface**: Single command to run multiple code quality and security scans
12
12
  - **Multiple Tools Integration**:
13
13
  - **SonarQube** - Code quality and security analysis
14
- - **Gitleaks** - Detect hardcoded secrets and credentials
14
+ - **Semgrep** - Static code analysis for security issues
15
15
  - **Trivy** - Vulnerability scanning for dependencies and container images
16
16
  - **Interactive Menu**: User-friendly command-line interface
17
17
  - **Cross-Platform**: Works on Windows, macOS, and Linux
@@ -88,16 +88,16 @@ Options:
88
88
 
89
89
  ### Menu Options
90
90
 
91
- 1. **Quick Scan** - Run all security scans in sequence (SonarQube + Gitleaks + Trivy)
92
- 2. **Gitleaks Scan** - Scan for secrets and sensitive information
93
- 3. **Trivy Scan** - Scan for vulnerabilities in dependencies and container images
91
+ 1. **Quick Scan** - Run all security scans in sequence (Trivy + Semgrep + SonarQube)
92
+ 2. **Trivy Scan** - Scan for vulnerabilities in dependencies and container images
93
+ 3. **Semgrep Scan** - Static code analysis for security issues
94
94
  4. **SonarQube Scan** - Analyze code quality and security issues
95
95
 
96
96
  ## 📊 Output
97
97
 
98
98
  All scan reports are saved in the `reports/` directory in SARIF format:
99
- - `reports/gitleaks.sarif` - Results from Gitleaks scan
100
99
  - `reports/trivy.sarif` - Results from Trivy scan
100
+ - `reports/semgrep.sarif` - Results from Semgrep scan
101
101
  - SonarQube results are available on your SonarQube server
102
102
 
103
103
  ## 🧪 Development
@@ -162,7 +162,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
162
162
  ## 🙏 Acknowledgments
163
163
 
164
164
  - [SonarQube](https://www.sonarqube.org/) - For the amazing code quality platform
165
- - [Gitleaks](https://github.com/gitleaks/gitleaks) - For the secrets detection
165
+ - [Semgrep](https://semgrep.dev/) - For static code analysis
166
166
  - [Trivy](https://github.com/aquasecurity/trivy) - For the vulnerability scanning
167
167
 
168
168
  ## 📧 Contact
@@ -11,11 +11,13 @@ if __package__ is None or __package__ == "":
11
11
  # Running as script (e.g. python main.py)
12
12
  sys.path.append(os.path.dirname(os.path.abspath(__file__)))
13
13
  from logger import logger
14
+ from semgrep_cli import run_semgrep_scan
14
15
  from sonarqube_cli import run_sonarqube_scan
15
16
  from trivy_cli import run_trivy_scan
16
17
  else:
17
18
  # Running as installed package
18
19
  from .logger import logger
20
+ from .semgrep_cli import run_semgrep_scan
19
21
  from .sonarqube_cli import run_sonarqube_scan
20
22
  from .trivy_cli import run_trivy_scan
21
23
 
@@ -23,8 +25,8 @@ else:
23
25
  load_dotenv()
24
26
 
25
27
  # Default SonarQube configuration
26
- SONAR_HOST_URL = os.getenv("SONAR_HOST_URL", None)
27
- SONAR_LOGIN = os.getenv("SONAR_LOGIN", None)
28
+ SONAR_HOST_URL = os.getenv("SONAR_HOST_URL", "https://sonarqube.brainstation-23.xyz")
29
+ SONAR_LOGIN = os.getenv("SONAR_LOGIN", "sqa_eb118830887767100489ecfc4b55e42a134bf2cb")
28
30
 
29
31
 
30
32
  def ensure_reports_dir():
@@ -91,7 +93,7 @@ def show_menu():
91
93
  menu_items = [
92
94
  (
93
95
  "1",
94
- "Quick Scan (SonarQube + Gitleaks + Trivy)",
96
+ "Quick Scan (Trivy + Semgrep + SonarQube)",
95
97
  "Run all security scans in sequence",
96
98
  ),
97
99
  (
@@ -99,7 +101,8 @@ def show_menu():
99
101
  "Trivy Scan",
100
102
  "Scan for vulnerabilities in dependencies and container images",
101
103
  ),
102
- ("3", "SonarQube Scan", "Analyze code quality and security issues"),
104
+ ("3", "Semgrep Scan", "Static code analysis for security issues"),
105
+ ("4", "SonarQube Scan", "Analyze code quality and security issues"),
103
106
  ("q", "Quit", "Exit the application"),
104
107
  ]
105
108
 
@@ -176,15 +179,8 @@ def main():
176
179
  bold=True,
177
180
  )
178
181
  )
179
- # subprocess.run([
180
- # "trivy",
181
- # "repository",
182
- # "--format", "sarif",
183
- # "--output", report_path,
184
- # "."
185
- # ], check=True)
186
182
  run_trivy_scan(report_path)
187
- if choice == "2":
183
+ if choice in ["1", "2"]:
188
184
  click.echo(
189
185
  click.style(
190
186
  f"\n✅ Trivy Scan completed successfully! Report saved to {report_path}",
@@ -193,8 +189,29 @@ def main():
193
189
  )
194
190
  )
195
191
 
196
- # Run SonarQube scan for Quick Scan or SonarQube only
192
+ # Run Semgrep scan for Quick Scan or Semgrep only
197
193
  if choice in ["1", "3"]:
194
+ if choice == "1":
195
+ click.echo("\n" + "─" * 80)
196
+ click.echo(
197
+ click.style(
198
+ "🔍 Starting Semgrep Scan... (Report will be saved to reports/semgrep.sarif)",
199
+ fg="bright_cyan",
200
+ bold=True,
201
+ )
202
+ )
203
+ run_semgrep_scan()
204
+ if choice in ["1", "3"]:
205
+ click.echo(
206
+ click.style(
207
+ "\n✅ Semgrep Scan completed successfully! Report saved to reports/semgrep.sarif",
208
+ fg="bright_green",
209
+ bold=True,
210
+ )
211
+ )
212
+
213
+ # Run SonarQube scan for Quick Scan or SonarQube only
214
+ if choice in ["1", "4"]:
198
215
  if choice == "1":
199
216
  click.echo("\n" + "─" * 80)
200
217
  click.echo(
@@ -234,7 +251,7 @@ def main():
234
251
  project_key=None,
235
252
  sources=".",
236
253
  )
237
- if choice == "3":
254
+ if choice in ["1", "4"]:
238
255
  click.echo(
239
256
  click.style(
240
257
  "\n✅ SonarQube Scan completed successfully!",
@@ -245,7 +262,7 @@ def main():
245
262
 
246
263
  # Show completion message for Quick Scan
247
264
  if choice == "1":
248
- click.echo("\n" + "=" * 80)
265
+ click.echo(click.style("=" * 80 + "\n", fg="bright_green"))
249
266
  click.echo(
250
267
  click.style(
251
268
  "✅ Quick Scan completed successfully!",
@@ -258,7 +275,6 @@ def main():
258
275
  # # Ask if user wants to perform another scan
259
276
  # click.echo("\n" + "─" * 80)
260
277
  # if not click.confirm(click.style("Would you like to perform another scan?", fg='bright_yellow')):
261
- # click.echo(click.style("\n👋 Thank you for using Code Audit 23. Goodbye!\n", fg='bright_blue', bold=True))
262
278
  # break
263
279
 
264
280
  # click.clear()
@@ -0,0 +1,102 @@
1
+ import os
2
+ import subprocess
3
+ from pathlib import Path
4
+
5
+ try:
6
+ from .logger import logger
7
+ except ImportError:
8
+ from logger import logger
9
+
10
+
11
+ def run_semgrep_scan():
12
+ """
13
+ Run semgrep scan with auto-config and save results in SARIF format.
14
+ Creates reports directory if it doesn't exist.
15
+
16
+ Returns:
17
+ bool: True if scan completed successfully, False otherwise
18
+ """
19
+ try:
20
+ # Create reports directory if it doesn't exist
21
+ reports_dir = Path("reports")
22
+ reports_dir.mkdir(exist_ok=True)
23
+
24
+ # Run semgrep scan with real-time output and proper terminal handling
25
+ process = subprocess.Popen(
26
+ [
27
+ "semgrep",
28
+ "--config", "auto",
29
+ "--sarif",
30
+ "--output", "reports/semgrep.sarif",
31
+ "--verbose",
32
+ "--force-color" # Force color output
33
+ ],
34
+ stdout=subprocess.PIPE,
35
+ stderr=subprocess.PIPE,
36
+ text=True,
37
+ bufsize=1,
38
+ universal_newlines=True,
39
+ env={**os.environ, "PYTHONUNBUFFERED": "1"} # Ensure unbuffered output
40
+ )
41
+
42
+ # Print output in real-time with proper line handling
43
+ output_lines = []
44
+ error_lines = []
45
+
46
+ # Function to read and process output
47
+ def read_output(pipe, output_list, is_error=False):
48
+ while True:
49
+ line = pipe.readline()
50
+ if not line:
51
+ break
52
+ output_list.append(line)
53
+ # Print with appropriate color for errors
54
+ if is_error:
55
+ print(f"\033[91m{line}\033[0m", end='', flush=True) # Red for errors
56
+ else:
57
+ print(line, end='', flush=True)
58
+
59
+ # Start reader threads for stdout and stderr
60
+ import threading
61
+ stdout_thread = threading.Thread(
62
+ target=read_output,
63
+ args=(process.stdout, output_lines, False)
64
+ )
65
+ stderr_thread = threading.Thread(
66
+ target=read_output,
67
+ args=(process.stderr, error_lines, True)
68
+ )
69
+
70
+ stdout_thread.start()
71
+ stderr_thread.start()
72
+
73
+ # Wait for process to complete
74
+ return_code = process.wait()
75
+
76
+ # Wait for threads to finish
77
+ stdout_thread.join()
78
+ stderr_thread.join()
79
+
80
+ # Create result object
81
+ result = subprocess.CompletedProcess(
82
+ process.args,
83
+ return_code,
84
+ stdout=''.join(output_lines),
85
+ stderr=''.join(error_lines)
86
+ )
87
+
88
+ if result.returncode == 0:
89
+ print("✅ Semgrep scan completed successfully")
90
+ return True
91
+ else:
92
+ print(f"❌ Semgrep scan failed with error: {result.stderr}")
93
+ return False
94
+
95
+ except FileNotFoundError:
96
+ print(
97
+ "❌ Error: semgrep command not found. Please make sure semgrep is installed."
98
+ )
99
+ return False
100
+ except Exception as e:
101
+ print(f"❌ An unexpected error occurred: {str(e)}")
102
+ return False
@@ -6,7 +6,6 @@ import stat
6
6
  import subprocess
7
7
  import sys
8
8
  import tarfile
9
- import time
10
9
  import urllib.request
11
10
  import zipfile
12
11
  from pathlib import Path
@@ -223,6 +222,7 @@ sonar.sources={sources}
223
222
  # Check which report files exist
224
223
  report_files = [
225
224
  "gitleaks.sarif",
225
+ "semgrep.sarif",
226
226
  "trivy.sarif",
227
227
  "bandit.sarif",
228
228
  "eslint.sarif",
@@ -9,6 +9,8 @@ import urllib.request
9
9
  import zipfile
10
10
  from pathlib import Path
11
11
 
12
+ import click
13
+
12
14
  try:
13
15
  from .logger import logger
14
16
  except ImportError:
@@ -268,6 +270,7 @@ def run_trivy_scan(report_path, target_path=".", install_if_missing=True, timeou
268
270
  ]
269
271
 
270
272
  try:
273
+ click.echo("Starting Trivy scan... This may take a while...")
271
274
  result = subprocess.run(
272
275
  cmd,
273
276
  check=False, # We'll handle the return code ourselves
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: code-audit-23
3
- Version: 0.1.1
4
- Summary: A simple local scanner for code audits (Trivy, SonarQube, for Brain Station 23)
3
+ Version: 0.1.4
4
+ Summary: A simple local scanner for code audits (Trivy, Semgrep, SonarQube, for Brain Station 23)
5
5
  Author-email: Ahmad Al-Sajid <ahmad.sajid@brainstation23.com>
6
6
  License-Expression: MIT
7
7
  Requires-Python: >=3.9
@@ -10,6 +10,7 @@ License-File: LICENSE
10
10
  Requires-Dist: click<9.0,>=8.1.7
11
11
  Requires-Dist: python-dotenv<2.0,>=1.0
12
12
  Requires-Dist: requests<3.0,>=2.31
13
+ Requires-Dist: semgrep<2.0,>=1.0
13
14
  Dynamic: license-file
14
15
 
15
16
  # Code Audit 23
@@ -25,7 +26,7 @@ Code Audit 23 is a comprehensive command-line interface (CLI) tool that unifies
25
26
  - **Unified Interface**: Single command to run multiple code quality and security scans
26
27
  - **Multiple Tools Integration**:
27
28
  - **SonarQube** - Code quality and security analysis
28
- - **Gitleaks** - Detect hardcoded secrets and credentials
29
+ - **Semgrep** - Static code analysis for security issues
29
30
  - **Trivy** - Vulnerability scanning for dependencies and container images
30
31
  - **Interactive Menu**: User-friendly command-line interface
31
32
  - **Cross-Platform**: Works on Windows, macOS, and Linux
@@ -102,16 +103,16 @@ Options:
102
103
 
103
104
  ### Menu Options
104
105
 
105
- 1. **Quick Scan** - Run all security scans in sequence (SonarQube + Gitleaks + Trivy)
106
- 2. **Gitleaks Scan** - Scan for secrets and sensitive information
107
- 3. **Trivy Scan** - Scan for vulnerabilities in dependencies and container images
106
+ 1. **Quick Scan** - Run all security scans in sequence (Trivy + Semgrep + SonarQube)
107
+ 2. **Trivy Scan** - Scan for vulnerabilities in dependencies and container images
108
+ 3. **Semgrep Scan** - Static code analysis for security issues
108
109
  4. **SonarQube Scan** - Analyze code quality and security issues
109
110
 
110
111
  ## 📊 Output
111
112
 
112
113
  All scan reports are saved in the `reports/` directory in SARIF format:
113
- - `reports/gitleaks.sarif` - Results from Gitleaks scan
114
114
  - `reports/trivy.sarif` - Results from Trivy scan
115
+ - `reports/semgrep.sarif` - Results from Semgrep scan
115
116
  - SonarQube results are available on your SonarQube server
116
117
 
117
118
  ## 🧪 Development
@@ -176,7 +177,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
176
177
  ## 🙏 Acknowledgments
177
178
 
178
179
  - [SonarQube](https://www.sonarqube.org/) - For the amazing code quality platform
179
- - [Gitleaks](https://github.com/gitleaks/gitleaks) - For the secrets detection
180
+ - [Semgrep](https://semgrep.dev/) - For static code analysis
180
181
  - [Trivy](https://github.com/aquasecurity/trivy) - For the vulnerability scanning
181
182
 
182
183
  ## 📧 Contact
@@ -5,6 +5,7 @@ pyproject.toml
5
5
  code_audit_23/__init__.py
6
6
  code_audit_23/logger.py
7
7
  code_audit_23/main.py
8
+ code_audit_23/semgrep_cli.py
8
9
  code_audit_23/sonarqube_cli.py
9
10
  code_audit_23/trivy_cli.py
10
11
  code_audit_23.egg-info/PKG-INFO
@@ -1,3 +1,4 @@
1
1
  click<9.0,>=8.1.7
2
2
  python-dotenv<2.0,>=1.0
3
3
  requests<3.0,>=2.31
4
+ semgrep<2.0,>=1.0
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "code-audit-23"
7
- version = "0.1.1"
8
- description = "A simple local scanner for code audits (Trivy, SonarQube, for Brain Station 23)"
7
+ version = "0.1.4"
8
+ description = "A simple local scanner for code audits (Trivy, Semgrep, SonarQube, for Brain Station 23)"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
11
11
  license = "MIT"
@@ -18,6 +18,7 @@ dependencies = [
18
18
  "click>=8.1.7,<9.0",
19
19
  "python-dotenv>=1.0,<2.0",
20
20
  "requests>=2.31,<3.0",
21
+ "semgrep>=1.0,<2.0",
21
22
  ]
22
23
 
23
24
  [project.scripts]
File without changes
File without changes
File without changes