linux-security-audit-tool 0.1.0__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.
@@ -0,0 +1,26 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .eggs/
7
+ *.egg
8
+ .env
9
+ .venv
10
+ venv/
11
+ env/
12
+ *.pyc
13
+ *.pyo
14
+ .pytest_cache/
15
+ .ruff_cache/
16
+ .mypy_cache/
17
+ htmlcov/
18
+ .coverage
19
+ .coverage.*
20
+ *.log
21
+ .DS_Store
22
+ .idea/
23
+ .vscode/
24
+ *.swp
25
+ *.swo
26
+ .hypothesis/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dario Clavijo
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,125 @@
1
+ Metadata-Version: 2.4
2
+ Name: linux-security-audit-tool
3
+ Version: 0.1.0
4
+ Summary: Comprehensive Linux security auditing and hardening tool
5
+ Project-URL: Homepage, https://github.com/daedalus/linux-security-audit-tool
6
+ Project-URL: Repository, https://github.com/daedalus/linux-security-audit-tool
7
+ Project-URL: Issues, https://github.com/daedalus/linux-security-audit-tool/issues
8
+ Author-email: Dario Clavijo <clavijodario@gmail.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Requires-Python: >=3.11
12
+ Requires-Dist: jinja2>=3.0.0
13
+ Requires-Dist: tabulate>=0.9.0
14
+ Provides-Extra: all
15
+ Requires-Dist: click>=8.0; extra == 'all'
16
+ Requires-Dist: hatch; extra == 'all'
17
+ Requires-Dist: hypothesis; extra == 'all'
18
+ Requires-Dist: mypy; extra == 'all'
19
+ Requires-Dist: pytest; extra == 'all'
20
+ Requires-Dist: pytest-asyncio; extra == 'all'
21
+ Requires-Dist: pytest-cov; extra == 'all'
22
+ Requires-Dist: pytest-mock; extra == 'all'
23
+ Requires-Dist: rich>=13.0; extra == 'all'
24
+ Requires-Dist: ruff; extra == 'all'
25
+ Provides-Extra: cli
26
+ Requires-Dist: click>=8.0; extra == 'cli'
27
+ Requires-Dist: rich>=13.0; extra == 'cli'
28
+ Provides-Extra: dev
29
+ Requires-Dist: hatch; extra == 'dev'
30
+ Requires-Dist: mypy; extra == 'dev'
31
+ Requires-Dist: ruff; extra == 'dev'
32
+ Provides-Extra: lint
33
+ Requires-Dist: mypy; extra == 'lint'
34
+ Requires-Dist: ruff; extra == 'lint'
35
+ Provides-Extra: test
36
+ Requires-Dist: hypothesis; extra == 'test'
37
+ Requires-Dist: pytest; extra == 'test'
38
+ Requires-Dist: pytest-asyncio; extra == 'test'
39
+ Requires-Dist: pytest-cov; extra == 'test'
40
+ Requires-Dist: pytest-mock; extra == 'test'
41
+ Description-Content-Type: text/markdown
42
+
43
+ # Linux Security Audit Tool
44
+
45
+ A comprehensive CLI tool for auditing Linux system security posture.
46
+
47
+ [![PyPI](https://img.shields.io/pypi/v/linux-security-audit-tool.svg)](https://pypi.org/project/linux-security-audit-tool/)
48
+ [![Python](https://img.shields.io/pypi/pyversions/linux-security-audit-tool.svg)](https://pypi.org/project/linux-security-audit-tool/)
49
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
50
+
51
+ ## Install
52
+
53
+ ```bash
54
+ pip install linux-security-audit-tool
55
+ ```
56
+
57
+ ## Usage
58
+
59
+ ```bash
60
+ security-audit --help
61
+ security-audit audit
62
+ security-audit audit -p 0 -1 # Run specific phases
63
+ security-audit audit -o report.md # Save markdown report
64
+ security-audit audit --quiet # Summary only
65
+ ```
66
+
67
+ ## CLI
68
+
69
+ ```bash
70
+ security-audit [OPTIONS] COMMAND [ARGS]...
71
+
72
+ Options:
73
+ --version Show the version and exit.
74
+ --help Show this message and exit.
75
+
76
+ Commands:
77
+ audit Run a full security audit.
78
+ version Show version information.
79
+ ```
80
+
81
+ ## Development
82
+
83
+ ```bash
84
+ git clone https://github.com/daedalus/linux-security-audit-tool.git
85
+ cd linux-security-audit-tool
86
+ pip install -e ".[test]"
87
+
88
+ # run tests
89
+ pytest
90
+
91
+ # format
92
+ ruff format src/ tests/
93
+
94
+ # lint
95
+ ruff check src/ tests/
96
+
97
+ # type check
98
+ mypy src/
99
+ ```
100
+
101
+ ## API
102
+
103
+ ```python
104
+ from security_audit import gather_context, run_identity_checks, calculate_security_score
105
+ from security_audit.core import Finding, Severity
106
+
107
+ # Run a full audit
108
+ context = gather_context()
109
+ findings = run_identity_checks()
110
+ score = calculate_security_score(findings)
111
+ ```
112
+
113
+ ## Audit Phases
114
+
115
+ The tool performs security checks across 9 phases:
116
+
117
+ - **Phase 0**: Context Gathering (hostname, OS, kernel)
118
+ - **Phase 1**: Identity & Access Control (users, sudo, SSH)
119
+ - **Phase 2**: Network Exposure (listening services, firewall)
120
+ - **Phase 3**: File System & Permissions (SUID, world-writable)
121
+ - **Phase 4**: Process & Service Posture (running services)
122
+ - **Phase 5**: Kernel & OS Hardening (sysctl, ASLR)
123
+ - **Phase 6**: Logging & Monitoring (auditd, logs)
124
+ - **Phase 7**: Package & Update Hygiene (updates, repos)
125
+ - **Phase 8**: Cryptographic Posture (SSH keys, TLS)
@@ -0,0 +1,83 @@
1
+ # Linux Security Audit Tool
2
+
3
+ A comprehensive CLI tool for auditing Linux system security posture.
4
+
5
+ [![PyPI](https://img.shields.io/pypi/v/linux-security-audit-tool.svg)](https://pypi.org/project/linux-security-audit-tool/)
6
+ [![Python](https://img.shields.io/pypi/pyversions/linux-security-audit-tool.svg)](https://pypi.org/project/linux-security-audit-tool/)
7
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install linux-security-audit-tool
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```bash
18
+ security-audit --help
19
+ security-audit audit
20
+ security-audit audit -p 0 -1 # Run specific phases
21
+ security-audit audit -o report.md # Save markdown report
22
+ security-audit audit --quiet # Summary only
23
+ ```
24
+
25
+ ## CLI
26
+
27
+ ```bash
28
+ security-audit [OPTIONS] COMMAND [ARGS]...
29
+
30
+ Options:
31
+ --version Show the version and exit.
32
+ --help Show this message and exit.
33
+
34
+ Commands:
35
+ audit Run a full security audit.
36
+ version Show version information.
37
+ ```
38
+
39
+ ## Development
40
+
41
+ ```bash
42
+ git clone https://github.com/daedalus/linux-security-audit-tool.git
43
+ cd linux-security-audit-tool
44
+ pip install -e ".[test]"
45
+
46
+ # run tests
47
+ pytest
48
+
49
+ # format
50
+ ruff format src/ tests/
51
+
52
+ # lint
53
+ ruff check src/ tests/
54
+
55
+ # type check
56
+ mypy src/
57
+ ```
58
+
59
+ ## API
60
+
61
+ ```python
62
+ from security_audit import gather_context, run_identity_checks, calculate_security_score
63
+ from security_audit.core import Finding, Severity
64
+
65
+ # Run a full audit
66
+ context = gather_context()
67
+ findings = run_identity_checks()
68
+ score = calculate_security_score(findings)
69
+ ```
70
+
71
+ ## Audit Phases
72
+
73
+ The tool performs security checks across 9 phases:
74
+
75
+ - **Phase 0**: Context Gathering (hostname, OS, kernel)
76
+ - **Phase 1**: Identity & Access Control (users, sudo, SSH)
77
+ - **Phase 2**: Network Exposure (listening services, firewall)
78
+ - **Phase 3**: File System & Permissions (SUID, world-writable)
79
+ - **Phase 4**: Process & Service Posture (running services)
80
+ - **Phase 5**: Kernel & OS Hardening (sysctl, ASLR)
81
+ - **Phase 6**: Logging & Monitoring (auditd, logs)
82
+ - **Phase 7**: Package & Update Hygiene (updates, repos)
83
+ - **Phase 8**: Cryptographic Posture (SSH keys, TLS)
@@ -0,0 +1,84 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "linux-security-audit-tool"
7
+ version = "0.1.0"
8
+ description = "Comprehensive Linux security auditing and hardening tool"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = {text = "MIT"}
12
+ authors = [{name = "Dario Clavijo", email = "clavijodario@gmail.com"}]
13
+ dependencies = ["jinja2>=3.0.0", "tabulate>=0.9.0"]
14
+
15
+ [project.optional-dependencies]
16
+ cli = ["click>=8.0", "rich>=13.0"]
17
+ dev = [
18
+ "ruff",
19
+ "mypy",
20
+ "hatch",
21
+ ]
22
+ test = [
23
+ "pytest",
24
+ "pytest-cov",
25
+ "pytest-mock",
26
+ "pytest-asyncio",
27
+ "hypothesis",
28
+ ]
29
+ lint = ["ruff", "mypy"]
30
+ all = ["linux-security-audit-tool[cli,dev,test,lint]"]
31
+
32
+ [project.scripts]
33
+ security-audit = "security_audit.cli:main"
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/daedalus/linux-security-audit-tool"
37
+ Repository = "https://github.com/daedalus/linux-security-audit-tool"
38
+ Issues = "https://github.com/daedalus/linux-security-audit-tool/issues"
39
+
40
+ [tool.hatch.build.targets.wheel]
41
+ packages = ["src/security_audit"]
42
+
43
+ [tool.hatch.build.targets.sdist]
44
+ include = ["src/security_audit"]
45
+
46
+ [tool.ruff]
47
+ line-length = 88
48
+ target-version = "py311"
49
+
50
+ [tool.ruff.lint]
51
+ select = ["E", "F", "W", "I", "UP", "ANN", "TCH", "N", "C4", "ARG"]
52
+ ignore = ["E501"]
53
+
54
+ [tool.ruff.lint.per-file-ignores]
55
+ "__init__.py" = ["F401"]
56
+
57
+ [tool.ruff.lint.pydocstyle]
58
+ convention = "google"
59
+
60
+ [tool.mypy]
61
+ python_version = "3.11"
62
+ strict = true
63
+ warn_return_any = true
64
+ warn_unused_ignores = true
65
+
66
+ [tool.pytest.ini_options]
67
+ testpaths = ["tests"]
68
+ addopts = "-v --tb=short --cov=src"
69
+ filterwarnings = ["ignore::DeprecationWarning"]
70
+
71
+ [tool.coverage.run]
72
+ source = ["src"]
73
+ branch = true
74
+
75
+ [tool.coverage.report]
76
+ exclude = ["tests/*", "*/__init__.py"]
77
+ exclude_lines = [
78
+ "pragma: no cover",
79
+ "def __repr__",
80
+ "raise AssertionError",
81
+ "raise NotImplementedError",
82
+ "if __name__ == .__main__.:",
83
+ "if TYPE_CHECKING:",
84
+ ]
@@ -0,0 +1,49 @@
1
+ """Linux Security Audit Tool - Comprehensive security auditing and hardening."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ from .core import AuditContext, Finding, Severity
8
+ from .phases import (
9
+ calculate_security_score,
10
+ classify_severity,
11
+ gather_context,
12
+ generate_markdown_report,
13
+ generate_remediation_script,
14
+ get_system_info,
15
+ run_crypto_checks,
16
+ run_filesystem_checks,
17
+ run_identity_checks,
18
+ run_kernel_checks,
19
+ run_logging_checks,
20
+ run_network_checks,
21
+ run_package_checks,
22
+ run_process_checks,
23
+ run_reporting,
24
+ )
25
+
26
+ if TYPE_CHECKING:
27
+ from .cli import cli
28
+
29
+ __all__ = [
30
+ "__version__",
31
+ "AuditContext",
32
+ "Finding",
33
+ "Severity",
34
+ "calculate_security_score",
35
+ "classify_severity",
36
+ "gather_context",
37
+ "generate_markdown_report",
38
+ "generate_remediation_script",
39
+ "get_system_info",
40
+ "run_crypto_checks",
41
+ "run_filesystem_checks",
42
+ "run_identity_checks",
43
+ "run_kernel_checks",
44
+ "run_logging_checks",
45
+ "run_network_checks",
46
+ "run_package_checks",
47
+ "run_process_checks",
48
+ "run_reporting",
49
+ ]
@@ -0,0 +1,6 @@
1
+ """CLI entry point for the security audit tool."""
2
+
3
+ from security_audit.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ raise SystemExit(main())
@@ -0,0 +1,241 @@
1
+ """Command-line interface for the Linux Security Audit Tool."""
2
+
3
+ import sys
4
+ from typing import Optional
5
+
6
+ import click
7
+ from rich import print as rprint
8
+ from rich.console import Console
9
+ from rich.progress import Progress, SpinnerColumn, TextColumn
10
+
11
+ from security_audit.core import Finding, Severity
12
+ from security_audit.phases import (
13
+ calculate_security_score,
14
+ gather_context,
15
+ generate_markdown_report,
16
+ run_crypto_checks,
17
+ run_filesystem_checks,
18
+ run_identity_checks,
19
+ run_kernel_checks,
20
+ run_logging_checks,
21
+ run_network_checks,
22
+ run_package_checks,
23
+ run_process_checks,
24
+ )
25
+
26
+ console = Console()
27
+
28
+
29
+ def print_finding(finding: Finding) -> None:
30
+ """Print a single finding with severity color.
31
+
32
+ Args:
33
+ finding: The Finding object to print.
34
+ """
35
+ colors = {
36
+ Severity.CRITICAL: "red bold",
37
+ Severity.HIGH: "red",
38
+ Severity.MEDIUM: "yellow",
39
+ Severity.LOW: "cyan",
40
+ Severity.INFO: "blue",
41
+ }
42
+ color = colors.get(finding.severity, "white")
43
+ rprint(
44
+ f"[{color}]{finding.severity.value}[/{color}] [{color}]{finding.check_id}[/{color}]: {finding.title}"
45
+ )
46
+
47
+
48
+ def print_summary(findings: list[Finding]) -> None:
49
+ """Print a summary table of findings.
50
+
51
+ Args:
52
+ findings: List of Finding objects.
53
+ """
54
+ from rich.table import Table
55
+
56
+ counts = {
57
+ Severity.CRITICAL: 0,
58
+ Severity.HIGH: 0,
59
+ Severity.MEDIUM: 0,
60
+ Severity.LOW: 0,
61
+ Severity.INFO: 0,
62
+ }
63
+ for f in findings:
64
+ counts[f.severity] += 1
65
+
66
+ table = Table(title="Audit Summary")
67
+ table.add_column("Severity", style="bold")
68
+ table.add_column("Count", justify="right")
69
+
70
+ table.add_row("[red bold]CRITICAL[/red bold]", str(counts[Severity.CRITICAL]))
71
+ table.add_row("[red]HIGH[/red]", str(counts[Severity.HIGH]))
72
+ table.add_row("[yellow]MEDIUM[/yellow]", str(counts[Severity.MEDIUM]))
73
+ table.add_row("[cyan]LOW[/cyan]", str(counts[Severity.LOW]))
74
+ table.add_row("[blue]INFO[/blue]", str(counts[Severity.INFO]))
75
+
76
+ console.print(table)
77
+
78
+
79
+ @click.group()
80
+ @click.version_option(version="0.1.0")
81
+ def cli() -> None:
82
+ """Linux Security Audit Tool - Comprehensive security auditing and hardening."""
83
+ pass
84
+
85
+
86
+ @cli.command()
87
+ @click.option(
88
+ "--output",
89
+ "-o",
90
+ type=click.Path(),
91
+ default=None,
92
+ help="Output file for report",
93
+ )
94
+ @click.option(
95
+ "--phases",
96
+ "-p",
97
+ multiple=True,
98
+ help="Specific phases to run (0-9)",
99
+ )
100
+ @click.option(
101
+ "--quiet",
102
+ "-q",
103
+ is_flag=True,
104
+ help="Suppress detailed output",
105
+ )
106
+ def audit(
107
+ output: str | None,
108
+ phases: tuple,
109
+ quiet: bool,
110
+ ) -> None:
111
+ """Run a full security audit."""
112
+ console.print("[bold blue]Linux Security Audit Tool v0.1.0[/bold blue]")
113
+ console.print()
114
+
115
+ all_findings = []
116
+ context = None
117
+
118
+ selected_phases = list(range(10)) if not phases else [int(p) for p in phases]
119
+
120
+ with Progress(
121
+ SpinnerColumn(),
122
+ TextColumn("[progress.description]{task.description}"),
123
+ console=console,
124
+ ) as progress:
125
+ if 0 in selected_phases:
126
+ task = progress.add_task("Gathering context...", total=None)
127
+ context = gather_context()
128
+ if not quiet:
129
+ console.print(f" Hostname: {context.hostname}")
130
+ console.print(f" Kernel: {context.kernel}")
131
+ progress.update(task, completed=True)
132
+
133
+ if 1 in selected_phases:
134
+ task = progress.add_task(
135
+ "Checking identity & access control...", total=None
136
+ )
137
+ findings = run_identity_checks()
138
+ all_findings.extend(findings)
139
+ if not quiet:
140
+ for f in findings:
141
+ print_finding(f)
142
+ progress.update(task, completed=True)
143
+
144
+ if 2 in selected_phases:
145
+ task = progress.add_task("Checking network exposure...", total=None)
146
+ findings = run_network_checks()
147
+ all_findings.extend(findings)
148
+ if not quiet:
149
+ for f in findings:
150
+ print_finding(f)
151
+ progress.update(task, completed=True)
152
+
153
+ if 3 in selected_phases:
154
+ task = progress.add_task(
155
+ "Checking file system & permissions...", total=None
156
+ )
157
+ findings = run_filesystem_checks()
158
+ all_findings.extend(findings)
159
+ if not quiet:
160
+ for f in findings:
161
+ print_finding(f)
162
+ progress.update(task, completed=True)
163
+
164
+ if 4 in selected_phases:
165
+ task = progress.add_task(
166
+ "Checking process & service posture...", total=None
167
+ )
168
+ findings = run_process_checks()
169
+ all_findings.extend(findings)
170
+ if not quiet:
171
+ for f in findings:
172
+ print_finding(f)
173
+ progress.update(task, completed=True)
174
+
175
+ if 5 in selected_phases:
176
+ task = progress.add_task("Checking kernel & OS hardening...", total=None)
177
+ findings = run_kernel_checks()
178
+ all_findings.extend(findings)
179
+ if not quiet:
180
+ for f in findings:
181
+ print_finding(f)
182
+ progress.update(task, completed=True)
183
+
184
+ if 6 in selected_phases:
185
+ task = progress.add_task("Checking logging & monitoring...", total=None)
186
+ findings = run_logging_checks()
187
+ all_findings.extend(findings)
188
+ if not quiet:
189
+ for f in findings:
190
+ print_finding(f)
191
+ progress.update(task, completed=True)
192
+
193
+ if 7 in selected_phases:
194
+ task = progress.add_task("Checking package hygiene...", total=None)
195
+ findings = run_package_checks()
196
+ all_findings.extend(findings)
197
+ if not quiet:
198
+ for f in findings:
199
+ print_finding(f)
200
+ progress.update(task, completed=True)
201
+
202
+ if 8 in selected_phases:
203
+ task = progress.add_task("Checking cryptographic posture...", total=None)
204
+ findings = run_crypto_checks()
205
+ all_findings.extend(findings)
206
+ if not quiet:
207
+ for f in findings:
208
+ print_finding(f)
209
+ progress.update(task, completed=True)
210
+
211
+ if 9 in selected_phases:
212
+ task = progress.add_task("Generating report...", total=None)
213
+ if context is None:
214
+ context = gather_context()
215
+ score = calculate_security_score(all_findings)
216
+ console.print(f"\n[bold]Security Score: {score}/100[/bold]")
217
+ progress.update(task, completed=True)
218
+
219
+ console.print()
220
+ print_summary(all_findings)
221
+
222
+ if output:
223
+ report = generate_markdown_report(context, all_findings)
224
+ with open(output, "w", encoding="utf-8") as f:
225
+ f.write(report)
226
+ console.print(f"\n[green]Report saved to {output}[/green]")
227
+
228
+
229
+ @cli.command()
230
+ def version() -> None:
231
+ """Show version information."""
232
+ console.print("Linux Security Audit Tool v0.1.0")
233
+
234
+
235
+ def main() -> int:
236
+ """Main entry point for the CLI."""
237
+ return cli()
238
+
239
+
240
+ if __name__ == "__main__":
241
+ raise SystemExit(main())