code-audit-23 0.1.1__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.

@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 BrainStation-23 (https://brainstation-23.com/)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ recursive-include code_audit_23/sonar-scanner *
@@ -0,0 +1,184 @@
1
+ Metadata-Version: 2.4
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)
5
+ Author-email: Ahmad Al-Sajid <ahmad.sajid@brainstation23.com>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: click<9.0,>=8.1.7
11
+ Requires-Dist: python-dotenv<2.0,>=1.0
12
+ Requires-Dist: requests<3.0,>=2.31
13
+ Dynamic: license-file
14
+
15
+ # Code Audit 23
16
+
17
+ [![PyPI Version](https://img.shields.io/pypi/v/code-audit-23.svg)](https://pypi.org/project/code-audit-23/)
18
+ [![Python Version](https://img.shields.io/pypi/pyversions/code-audit-23.svg)](https://pypi.org/project/code-audit-23/)
19
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
20
+
21
+ Code Audit 23 is a comprehensive command-line interface (CLI) tool that unifies multiple code quality and security scanning tools into a single, easy-to-use interface. It's designed to help developers maintain high code quality and security standards across their projects.
22
+
23
+ ## โœจ Features
24
+
25
+ - **Unified Interface**: Single command to run multiple code quality and security scans
26
+ - **Multiple Tools Integration**:
27
+ - **SonarQube** - Code quality and security analysis
28
+ - **Gitleaks** - Detect hardcoded secrets and credentials
29
+ - **Trivy** - Vulnerability scanning for dependencies and container images
30
+ - **Interactive Menu**: User-friendly command-line interface
31
+ - **Cross-Platform**: Works on Windows, macOS, and Linux
32
+ - **SARIF Reports**: Standardized output format for all scan results
33
+ - **No Installation Required**: Self-contained executable available
34
+
35
+ ## ๐Ÿš€ Installation
36
+
37
+ ### Prerequisites
38
+
39
+ - Python 3.9 or higher
40
+ - Java 11+ (for SonarQube Scanner)
41
+ - [Git](https://git-scm.com/) (for Gitleaks)
42
+
43
+ ### Install from PyPI
44
+
45
+ ```bash
46
+ pip install code-audit-23
47
+ ```
48
+
49
+ ### Install from Source
50
+
51
+ 1. Clone the repository:
52
+ ```bash
53
+ git clone https://github.com/BrainStation-23/CodeAudit23.git
54
+ cd CodeAudit23
55
+ ```
56
+
57
+ 2. Create and activate a virtual environment:
58
+ ```bash
59
+ # Linux/macOS
60
+ python -m venv venv
61
+ source venv/bin/activate
62
+
63
+ # Windows
64
+ python -m venv venv
65
+ .\venv\Scripts\activate
66
+ ```
67
+
68
+ 3. Install dependencies:
69
+ ```bash
70
+ pip install -e .
71
+ ```
72
+
73
+ ## ๐Ÿ”ง Configuration
74
+
75
+ 1. Create a `.env` file in your project root with the following variables:
76
+ ```env
77
+ SONAR_HOST_URL=https://your-sonarqube-instance.com
78
+ SONAR_LOGIN=your_sonarqube_token
79
+ ```
80
+
81
+ 2. The first time you run a scan, the tool will prompt you for SonarQube credentials if they're not in the `.env` file.
82
+
83
+ ## ๐Ÿ›  Usage
84
+
85
+ ### Basic Usage
86
+
87
+ Run the interactive menu:
88
+ ```bash
89
+ code-audit-23
90
+ ```
91
+
92
+ ### Command Line Options
93
+
94
+ ```
95
+ Usage: code-audit-23 [OPTIONS]
96
+
97
+ Interactive entrypoint for Audit Scanner
98
+
99
+ Options:
100
+ --help Show this message and exit.
101
+ ```
102
+
103
+ ### Menu Options
104
+
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
108
+ 4. **SonarQube Scan** - Analyze code quality and security issues
109
+
110
+ ## ๐Ÿ“Š Output
111
+
112
+ All scan reports are saved in the `reports/` directory in SARIF format:
113
+ - `reports/gitleaks.sarif` - Results from Gitleaks scan
114
+ - `reports/trivy.sarif` - Results from Trivy scan
115
+ - SonarQube results are available on your SonarQube server
116
+
117
+ ## ๐Ÿงช Development
118
+
119
+ ### Project Structure
120
+
121
+ ```
122
+ code_audit_23/
123
+ โ”œโ”€โ”€ __init__.py
124
+ โ”œโ”€โ”€ main.py # Main CLI entry point
125
+ โ”œโ”€โ”€ sonarqube_cli.py # SonarQube scanner implementation
126
+ โ””โ”€โ”€ logger.py # Logging configuration
127
+ ```
128
+
129
+ ### Dependencies
130
+
131
+ - `click` - Command line interface creation
132
+ - `requests` - HTTP requests
133
+ - `python-dotenv` - Environment variable management
134
+
135
+ ### Building & Publishing to PyPI
136
+
137
+ 1. Update the version in `pyproject.toml` (and optionally `__init__.py` if you mirror it there). Commit the change.
138
+ 2. Ensure you have the packaging tooling:
139
+ ```bash
140
+ python -m pip install --upgrade build twine
141
+ ```
142
+ 3. Clean any previous artifacts:
143
+ ```bash
144
+ rm -rf dist build *.egg-info
145
+ ```
146
+ 4. Build the source distribution and wheel:
147
+ ```bash
148
+ python -m build
149
+ ```
150
+ 5. (Optional but recommended) Validate the archives locally:
151
+ ```bash
152
+ twine check dist/*
153
+ ```
154
+ 6. (Optional) Publish to TestPyPI before the main release:
155
+ ```bash
156
+ python -m twine upload --repository testpypi dist/*
157
+ ```
158
+ 7. Once satisfied, publish to PyPI:
159
+ ```bash
160
+ python -m twine upload dist/*
161
+ ```
162
+ 8. Tag the release in git, e.g.:
163
+ ```bash
164
+ git tag -a v0.1.0 -m "Release v0.1.0"
165
+ git push origin v0.1.0
166
+ ```
167
+
168
+ ## ๐Ÿค Contributing
169
+
170
+ Contributions are welcome! Please read our [Contributing Guidelines](./CONTRIBUTING.md) for details on how to submit pull requests, report issues, or suggest new features.
171
+
172
+ ## ๐Ÿ“„ License
173
+
174
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
175
+
176
+ ## ๐Ÿ™ Acknowledgments
177
+
178
+ - [SonarQube](https://www.sonarqube.org/) - For the amazing code quality platform
179
+ - [Gitleaks](https://github.com/gitleaks/gitleaks) - For the secrets detection
180
+ - [Trivy](https://github.com/aquasecurity/trivy) - For the vulnerability scanning
181
+
182
+ ## ๐Ÿ“ง Contact
183
+
184
+ For any questions or feedback, please contact [Ahmad Al-Sajid](mailto:ahmad.sajid@brainstation-23.com).
@@ -0,0 +1,170 @@
1
+ # Code Audit 23
2
+
3
+ [![PyPI Version](https://img.shields.io/pypi/v/code-audit-23.svg)](https://pypi.org/project/code-audit-23/)
4
+ [![Python Version](https://img.shields.io/pypi/pyversions/code-audit-23.svg)](https://pypi.org/project/code-audit-23/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ Code Audit 23 is a comprehensive command-line interface (CLI) tool that unifies multiple code quality and security scanning tools into a single, easy-to-use interface. It's designed to help developers maintain high code quality and security standards across their projects.
8
+
9
+ ## โœจ Features
10
+
11
+ - **Unified Interface**: Single command to run multiple code quality and security scans
12
+ - **Multiple Tools Integration**:
13
+ - **SonarQube** - Code quality and security analysis
14
+ - **Gitleaks** - Detect hardcoded secrets and credentials
15
+ - **Trivy** - Vulnerability scanning for dependencies and container images
16
+ - **Interactive Menu**: User-friendly command-line interface
17
+ - **Cross-Platform**: Works on Windows, macOS, and Linux
18
+ - **SARIF Reports**: Standardized output format for all scan results
19
+ - **No Installation Required**: Self-contained executable available
20
+
21
+ ## ๐Ÿš€ Installation
22
+
23
+ ### Prerequisites
24
+
25
+ - Python 3.9 or higher
26
+ - Java 11+ (for SonarQube Scanner)
27
+ - [Git](https://git-scm.com/) (for Gitleaks)
28
+
29
+ ### Install from PyPI
30
+
31
+ ```bash
32
+ pip install code-audit-23
33
+ ```
34
+
35
+ ### Install from Source
36
+
37
+ 1. Clone the repository:
38
+ ```bash
39
+ git clone https://github.com/BrainStation-23/CodeAudit23.git
40
+ cd CodeAudit23
41
+ ```
42
+
43
+ 2. Create and activate a virtual environment:
44
+ ```bash
45
+ # Linux/macOS
46
+ python -m venv venv
47
+ source venv/bin/activate
48
+
49
+ # Windows
50
+ python -m venv venv
51
+ .\venv\Scripts\activate
52
+ ```
53
+
54
+ 3. Install dependencies:
55
+ ```bash
56
+ pip install -e .
57
+ ```
58
+
59
+ ## ๐Ÿ”ง Configuration
60
+
61
+ 1. Create a `.env` file in your project root with the following variables:
62
+ ```env
63
+ SONAR_HOST_URL=https://your-sonarqube-instance.com
64
+ SONAR_LOGIN=your_sonarqube_token
65
+ ```
66
+
67
+ 2. The first time you run a scan, the tool will prompt you for SonarQube credentials if they're not in the `.env` file.
68
+
69
+ ## ๐Ÿ›  Usage
70
+
71
+ ### Basic Usage
72
+
73
+ Run the interactive menu:
74
+ ```bash
75
+ code-audit-23
76
+ ```
77
+
78
+ ### Command Line Options
79
+
80
+ ```
81
+ Usage: code-audit-23 [OPTIONS]
82
+
83
+ Interactive entrypoint for Audit Scanner
84
+
85
+ Options:
86
+ --help Show this message and exit.
87
+ ```
88
+
89
+ ### Menu Options
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
94
+ 4. **SonarQube Scan** - Analyze code quality and security issues
95
+
96
+ ## ๐Ÿ“Š Output
97
+
98
+ All scan reports are saved in the `reports/` directory in SARIF format:
99
+ - `reports/gitleaks.sarif` - Results from Gitleaks scan
100
+ - `reports/trivy.sarif` - Results from Trivy scan
101
+ - SonarQube results are available on your SonarQube server
102
+
103
+ ## ๐Ÿงช Development
104
+
105
+ ### Project Structure
106
+
107
+ ```
108
+ code_audit_23/
109
+ โ”œโ”€โ”€ __init__.py
110
+ โ”œโ”€โ”€ main.py # Main CLI entry point
111
+ โ”œโ”€โ”€ sonarqube_cli.py # SonarQube scanner implementation
112
+ โ””โ”€โ”€ logger.py # Logging configuration
113
+ ```
114
+
115
+ ### Dependencies
116
+
117
+ - `click` - Command line interface creation
118
+ - `requests` - HTTP requests
119
+ - `python-dotenv` - Environment variable management
120
+
121
+ ### Building & Publishing to PyPI
122
+
123
+ 1. Update the version in `pyproject.toml` (and optionally `__init__.py` if you mirror it there). Commit the change.
124
+ 2. Ensure you have the packaging tooling:
125
+ ```bash
126
+ python -m pip install --upgrade build twine
127
+ ```
128
+ 3. Clean any previous artifacts:
129
+ ```bash
130
+ rm -rf dist build *.egg-info
131
+ ```
132
+ 4. Build the source distribution and wheel:
133
+ ```bash
134
+ python -m build
135
+ ```
136
+ 5. (Optional but recommended) Validate the archives locally:
137
+ ```bash
138
+ twine check dist/*
139
+ ```
140
+ 6. (Optional) Publish to TestPyPI before the main release:
141
+ ```bash
142
+ python -m twine upload --repository testpypi dist/*
143
+ ```
144
+ 7. Once satisfied, publish to PyPI:
145
+ ```bash
146
+ python -m twine upload dist/*
147
+ ```
148
+ 8. Tag the release in git, e.g.:
149
+ ```bash
150
+ git tag -a v0.1.0 -m "Release v0.1.0"
151
+ git push origin v0.1.0
152
+ ```
153
+
154
+ ## ๐Ÿค Contributing
155
+
156
+ Contributions are welcome! Please read our [Contributing Guidelines](./CONTRIBUTING.md) for details on how to submit pull requests, report issues, or suggest new features.
157
+
158
+ ## ๐Ÿ“„ License
159
+
160
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
161
+
162
+ ## ๐Ÿ™ Acknowledgments
163
+
164
+ - [SonarQube](https://www.sonarqube.org/) - For the amazing code quality platform
165
+ - [Gitleaks](https://github.com/gitleaks/gitleaks) - For the secrets detection
166
+ - [Trivy](https://github.com/aquasecurity/trivy) - For the vulnerability scanning
167
+
168
+ ## ๐Ÿ“ง Contact
169
+
170
+ For any questions or feedback, please contact [Ahmad Al-Sajid](mailto:ahmad.sajid@brainstation-23.com).
File without changes
@@ -0,0 +1,62 @@
1
+ import logging
2
+ import os
3
+ import sys
4
+ from logging.handlers import RotatingFileHandler
5
+ from pathlib import Path
6
+
7
+ from dotenv import load_dotenv
8
+
9
+ load_dotenv()
10
+
11
+ LOG_LEVEL = os.getenv("LOG_LEVEL", "WARNING").upper()
12
+
13
+
14
+ def setup_logger(name):
15
+ """
16
+ Set up a logger with both file and console handlers.
17
+ Logs are stored in the directory where the command is executed.
18
+ """
19
+
20
+ # Always use the current working directory for logs
21
+ log_dir = Path.cwd() / "logs"
22
+
23
+ # Create logs directory if missing
24
+ log_dir.mkdir(parents=True, exist_ok=True)
25
+
26
+ # Initialize logger
27
+ logger = logging.getLogger(name)
28
+ logger.setLevel(LOG_LEVEL)
29
+
30
+ # Prevent duplicate handlers
31
+ if logger.hasHandlers():
32
+ return logger
33
+
34
+ # Formatters
35
+ file_formatter = logging.Formatter(
36
+ "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
37
+ datefmt="%Y-%m-%d %H:%M:%S",
38
+ )
39
+ console_formatter = logging.Formatter("%(levelname)-8s %(message)s")
40
+
41
+ # File handler (rotating)
42
+ log_file = log_dir / "audit_scanner.log"
43
+ file_handler = RotatingFileHandler(
44
+ log_file, maxBytes=5 * 1024 * 1024, backupCount=3, encoding="utf-8"
45
+ )
46
+ file_handler.setLevel(LOG_LEVEL)
47
+ file_handler.setFormatter(file_formatter)
48
+
49
+ # Console handler
50
+ console_handler = logging.StreamHandler()
51
+ console_handler.setLevel(LOG_LEVEL)
52
+ console_handler.setFormatter(console_formatter)
53
+
54
+ # Add handlers
55
+ logger.addHandler(file_handler)
56
+ logger.addHandler(console_handler)
57
+
58
+ return logger
59
+
60
+
61
+ # Default logger instance
62
+ logger = setup_logger(__name__)