build files
- SHA
8dab5854d44493e2371e0ecafd39faf367d451db- Tree
916a11e
8dab585
8dab5854d44493e2371e0ecafd39faf367d451db916a11e| Status | File | + | - |
|---|---|---|---|
| A |
pyproject.toml
|
80 | 0 |
| A |
src/sultree/__init__.py
|
13 | 0 |
| A |
src/sultree/__main__.py
|
40 | 0 |
pyproject.tomladded@@ -0,0 +1,80 @@ | ||
| 1 | +[build-system] | |
| 2 | +requires = ["setuptools>=61.0", "wheel"] | |
| 3 | +build-backend = "setuptools.build_meta" | |
| 4 | + | |
| 5 | +[project] | |
| 6 | +name = "sultree" | |
| 7 | +version = "0.1.0" | |
| 8 | +description = "SELinux-aware tree command - displays directory trees filtered by SELinux security contexts" | |
| 9 | +readme = "README.md" | |
| 10 | +requires-python = ">=3.8" | |
| 11 | +license = {text = "MIT"} | |
| 12 | +authors = [ | |
| 13 | + {name = "mfw", email = "espadon@outlook.com"}, | |
| 14 | +] | |
| 15 | +keywords = ["tree", "selinux", "security", "filesystem", "cli"] | |
| 16 | +classifiers = [ | |
| 17 | + "Development Status :: 3 - Alpha", | |
| 18 | + "Environment :: Console", | |
| 19 | + "Intended Audience :: System Administrators", | |
| 20 | + "License :: OSI Approved :: MIT License", | |
| 21 | + "Operating System :: POSIX :: Linux", | |
| 22 | + "Programming Language :: Python :: 3", | |
| 23 | + "Programming Language :: Python :: 3.8", | |
| 24 | + "Programming Language :: Python :: 3.9", | |
| 25 | + "Programming Language :: Python :: 3.10", | |
| 26 | + "Programming Language :: Python :: 3.11", | |
| 27 | + "Programming Language :: Python :: 3.12", | |
| 28 | + "Topic :: System :: Systems Administration", | |
| 29 | + "Topic :: Security", | |
| 30 | +] | |
| 31 | +dependencies = [] | |
| 32 | + | |
| 33 | +[project.optional-dependencies] | |
| 34 | +dev = [ | |
| 35 | + "pytest>=7.0.0", | |
| 36 | + "pytest-cov>=4.0.0", | |
| 37 | + "black>=22.0.0", | |
| 38 | + "flake8>=6.0.0", | |
| 39 | + "mypy>=1.0.0", | |
| 40 | + "bandit>=1.7.0", # Security linting | |
| 41 | + "safety>=2.0.0", # Dependency security scanning | |
| 42 | +] | |
| 43 | + | |
| 44 | +[project.scripts] | |
| 45 | +sultree = "sultree.__main__:main" | |
| 46 | + | |
| 47 | +[project.urls] | |
| 48 | +# Homepage = "https://github.com/username/sultree" | |
| 49 | +# Repository = "https://github.com/username/sultree" | |
| 50 | +# Issues = "https://github.com/username/sultree/issues" | |
| 51 | + | |
| 52 | +[tool.setuptools.packages.find] | |
| 53 | +where = ["src"] | |
| 54 | + | |
| 55 | +[tool.setuptools.package-dir] | |
| 56 | +"" = "src" | |
| 57 | + | |
| 58 | +# Security-focused linting configuration | |
| 59 | +[tool.bandit] | |
| 60 | +exclude_dirs = ["tests"] | |
| 61 | +skips = [] | |
| 62 | + | |
| 63 | +[tool.black] | |
| 64 | +line-length = 88 | |
| 65 | +target-version = ["py38"] | |
| 66 | + | |
| 67 | +[tool.mypy] | |
| 68 | +python_version = "3.8" | |
| 69 | +warn_return_any = true | |
| 70 | +warn_unused_configs = true | |
| 71 | +disallow_untyped_defs = true | |
| 72 | +disallow_incomplete_defs = true | |
| 73 | +check_untyped_defs = true | |
| 74 | +warn_redundant_casts = true | |
| 75 | +warn_unused_ignores = true | |
| 76 | +strict_optional = true | |
| 77 | + | |
| 78 | +[tool.pytest.ini_options] | |
| 79 | +testpaths = ["tests"] | |
| 80 | +addopts = "--cov=sultree --cov-report=html --cov-report=term-missing" | |
src/sultree/__init__.pyadded@@ -0,0 +1,13 @@ | ||
| 1 | +""" | |
| 2 | +sultree - SELinux-aware tree command | |
| 3 | + | |
| 4 | +A variant of the tree command that filters directory trees based on SELinux security contexts. | |
| 5 | +Provides all the functionality of tree with additional SELinux label filtering capabilities. | |
| 6 | +""" | |
| 7 | + | |
| 8 | +__version__ = "0.1.0" | |
| 9 | +__author__ = "mfw" | |
| 10 | +__email__ = "espadonne@outlook.com" | |
| 11 | + | |
| 12 | +# Security note: This module only imports from standard library and our own modules | |
| 13 | +# to minimize attack surface | |
src/sultree/__main__.pyadded@@ -0,0 +1,40 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +""" | |
| 3 | +Main entry point for sultree command-line interface. | |
| 4 | + | |
| 5 | +This module provides the CLI interface and orchestrates all other components. | |
| 6 | +Security considerations: | |
| 7 | +- Input validation on all command-line arguments | |
| 8 | +- Proper error handling to prevent information leakage | |
| 9 | +- Safe path handling to prevent directory traversal attacks | |
| 10 | +""" | |
| 11 | + | |
| 12 | +import sys | |
| 13 | +from typing import NoReturn | |
| 14 | + | |
| 15 | +from .cli import main as cli_main | |
| 16 | + | |
| 17 | + | |
| 18 | +def main() -> NoReturn: | |
| 19 | + """ | |
| 20 | + Main entry point for sultree CLI. | |
| 21 | + | |
| 22 | + Exits with appropriate status codes: | |
| 23 | + 0: Success | |
| 24 | + 1: General error | |
| 25 | + 2: Invalid command-line arguments | |
| 26 | + 3: Permission denied or SELinux access error | |
| 27 | + """ | |
| 28 | + try: | |
| 29 | + exit_code = cli_main() | |
| 30 | + sys.exit(exit_code) | |
| 31 | + except KeyboardInterrupt: | |
| 32 | + sys.exit(130) # Standard exit code for Ctrl+C | |
| 33 | + except Exception as e: | |
| 34 | + # Security: Don't leak sensitive information in error messages | |
| 35 | + print(f"sultree: unexpected error occurred", file=sys.stderr) | |
| 36 | + sys.exit(1) | |
| 37 | + | |
| 38 | + | |
| 39 | +if __name__ == "__main__": | |
| 40 | + main() | |