security-pentest-planner 1.0.2__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.
Files changed (26) hide show
  1. security_pentest_planner-1.0.2/LICENSE +21 -0
  2. security_pentest_planner-1.0.2/PKG-INFO +164 -0
  3. security_pentest_planner-1.0.2/README.md +141 -0
  4. security_pentest_planner-1.0.2/pyproject.toml +39 -0
  5. security_pentest_planner-1.0.2/setup.cfg +4 -0
  6. security_pentest_planner-1.0.2/setup.py +4 -0
  7. security_pentest_planner-1.0.2/src/security_pentest_planner/__init__.py +48 -0
  8. security_pentest_planner-1.0.2/src/security_pentest_planner/__main__.py +8 -0
  9. security_pentest_planner-1.0.2/src/security_pentest_planner/cli.py +65 -0
  10. security_pentest_planner-1.0.2/src/security_pentest_planner/contract_analyzer.py +219 -0
  11. security_pentest_planner-1.0.2/src/security_pentest_planner/errors.py +14 -0
  12. security_pentest_planner-1.0.2/src/security_pentest_planner/models.py +111 -0
  13. security_pentest_planner-1.0.2/src/security_pentest_planner/openapi_parser.py +203 -0
  14. security_pentest_planner-1.0.2/src/security_pentest_planner/plan_renderer.py +270 -0
  15. security_pentest_planner-1.0.2/src/security_pentest_planner/planner.py +84 -0
  16. security_pentest_planner-1.0.2/src/security_pentest_planner/vector_catalog.py +438 -0
  17. security_pentest_planner-1.0.2/src/security_pentest_planner/version.py +4 -0
  18. security_pentest_planner-1.0.2/src/security_pentest_planner.egg-info/PKG-INFO +164 -0
  19. security_pentest_planner-1.0.2/src/security_pentest_planner.egg-info/SOURCES.txt +24 -0
  20. security_pentest_planner-1.0.2/src/security_pentest_planner.egg-info/dependency_links.txt +1 -0
  21. security_pentest_planner-1.0.2/src/security_pentest_planner.egg-info/entry_points.txt +2 -0
  22. security_pentest_planner-1.0.2/src/security_pentest_planner.egg-info/requires.txt +1 -0
  23. security_pentest_planner-1.0.2/src/security_pentest_planner.egg-info/top_level.txt +1 -0
  24. security_pentest_planner-1.0.2/tests/test_contract_analyzer.py +36 -0
  25. security_pentest_planner-1.0.2/tests/test_openapi_parser.py +48 -0
  26. security_pentest_planner-1.0.2/tests/test_planner.py +48 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Saulo Filho
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,164 @@
1
+ Metadata-Version: 2.4
2
+ Name: security-pentest-planner
3
+ Version: 1.0.2
4
+ Summary: Generate pentest action plans from OpenAPI specifications
5
+ Author-email: Saulo Filho <saulofilho@users.noreply.github.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://saulofilho.github.io/security-pentest-planner/
8
+ Project-URL: Repository, https://github.com/saulofilho/security-pentest-planner-python
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Information Technology
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Security
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: pyyaml>=6.0
22
+ Dynamic: license-file
23
+
24
+ # security-pentest-planner
25
+
26
+ [![PyPI version](https://badge.fury.io/py/security-pentest-planner.svg)](https://badge.fury.io/py/security-pentest-planner)
27
+ [![Python Versions](https://img.shields.io/pypi/pyversions/security-pentest-planner.svg)](https://pypi.org/project/security-pentest-planner/)
28
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
29
+
30
+ **Site:** [saulofilho.github.io/security-pentest-planner](https://saulofilho.github.io/security-pentest-planner/)
31
+
32
+ Gera **Planos de Ação de Pentest** a partir de especificações OpenAPI/Swagger.
33
+
34
+ Ferramenta open source para times de engenharia e AppSec que precisam estruturar testes ofensivos **antes** da execução — com vetores OWASP, procedimentos, payloads e critérios de validação.
35
+
36
+ ## O que ela faz
37
+
38
+ - Analisa contratos **OpenAPI 3.x** (YAML ou JSON)
39
+ - Detecta sinais de risco: tenant headers, parâmetros de data, enums, timezone livre
40
+ - Seleciona vetores OWASP API Security aplicáveis via taxonomia
41
+ - Gera um **design doc** em Markdown com:
42
+ - Procedimentos passo a passo por vetor
43
+ - Payloads e exemplos HTTP/SQL
44
+ - Tabela resumo (Acesso · Entrada · Disponibilidade · Informação)
45
+ - Recomendações imediatas de remediação
46
+ - Red flags do contrato
47
+
48
+ ## O que ela NÃO faz
49
+
50
+ - Scripts executáveis (Requests, Python, SQL runnable)
51
+ - Resultados de teste (APROVADO/REPROVADO)
52
+ - RFCs de implementação
53
+
54
+ Esses artefatos pertencem à **fase de execução** do pentest.
55
+
56
+ ## Instalação
57
+
58
+ ```bash
59
+ pip install security-pentest-planner
60
+ ```
61
+
62
+ Ou usando `uv` / `poetry`:
63
+
64
+ ```bash
65
+ uv add security-pentest-planner
66
+ # ou
67
+ poetry add security-pentest-planner
68
+ ```
69
+
70
+ ## Uso via CLI
71
+
72
+ ```bash
73
+ # Gerar plano no stdout
74
+ security-pentest-planner swagger/v2/swagger.json
75
+
76
+ # Salvar em arquivo
77
+ security-pentest-planner openapi.yaml -o plano-de-acao-pentest.md
78
+
79
+ # Com escopo e Data Lake
80
+ security-pentest-planner openapi.yaml \
81
+ --team "Platform Team" \
82
+ --scope /api/v1/metrics \
83
+ --datalake \
84
+ -o plano.md
85
+ ```
86
+
87
+ ### Opções
88
+
89
+ | Flag | Descrição |
90
+ |------|-----------|
91
+ | `-t, --team TEAM` | Nome do time no título |
92
+ | `-s, --scope PATH` | Limitar a um endpoint |
93
+ | `-d, --datalake` | Incluir vetores de Data Lake |
94
+ | `--api-layer NAME` | Nome da camada API (default: API) |
95
+ | `--data-layer NAME` | Nome da camada Data Lake (default: Data Lake) |
96
+ | `-o, --output FILE` | Salvar em arquivo |
97
+ | `-v, --version` | Exibe a versão |
98
+ | `-h, --help` | Exibe a ajuda |
99
+
100
+ ## Uso programático
101
+
102
+ ```python
103
+ import security_pentest_planner
104
+
105
+ # A partir de arquivo
106
+ plan = security_pentest_planner.generate(
107
+ input_path="openapi.yaml",
108
+ team="Platform Team",
109
+ scope="/api/v1/metrics",
110
+ include_datalake=True,
111
+ )
112
+
113
+ with open("plano-de-acao-pentest.md", "w", encoding="utf-8") as f:
114
+ f.write(plan)
115
+
116
+ # A partir de um dicionário (spec já carregada)
117
+ import yaml
118
+
119
+ with open("openapi.yaml", "r", encoding="utf-8") as f:
120
+ spec_data = yaml.safe_load(f)
121
+
122
+ plan = security_pentest_planner.generate_from_spec(
123
+ spec=spec_data,
124
+ team="Security Team",
125
+ )
126
+ ```
127
+
128
+ ## Publicar no PyPI
129
+
130
+ ```bash
131
+ python -m pip install build twine
132
+ python -m build
133
+ python -m twine upload dist/*
134
+ ```
135
+
136
+ ## Desenvolvimento e Testes
137
+
138
+ ```bash
139
+ git clone https://github.com/saulofilho/security-pentest-planner-python.git
140
+ cd security-pentest-planner-python
141
+
142
+ # Executar testes unitários
143
+ python3 -m unittest discover -s tests -v
144
+
145
+ # Ou com pytest
146
+ pytest -v
147
+ ```
148
+
149
+ ## Fluxo recomendado
150
+
151
+ ```
152
+ OpenAPI spec → security-pentest-planner → Plano de Ação (Markdown)
153
+
154
+ Execução manual / CI
155
+
156
+ Resultados + RFCs
157
+ ```
158
+
159
+ O pacote cobre a fase de **planejamento** de forma determinística — ideal para CI/CD, pipelines e integração em projetos Python/FastAPI/Django/Flask.
160
+
161
+ ## Licença
162
+
163
+ MIT — veja [LICENSE](LICENSE).
164
+
@@ -0,0 +1,141 @@
1
+ # security-pentest-planner
2
+
3
+ [![PyPI version](https://badge.fury.io/py/security-pentest-planner.svg)](https://badge.fury.io/py/security-pentest-planner)
4
+ [![Python Versions](https://img.shields.io/pypi/pyversions/security-pentest-planner.svg)](https://pypi.org/project/security-pentest-planner/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+
7
+ **Site:** [saulofilho.github.io/security-pentest-planner](https://saulofilho.github.io/security-pentest-planner/)
8
+
9
+ Gera **Planos de Ação de Pentest** a partir de especificações OpenAPI/Swagger.
10
+
11
+ Ferramenta open source para times de engenharia e AppSec que precisam estruturar testes ofensivos **antes** da execução — com vetores OWASP, procedimentos, payloads e critérios de validação.
12
+
13
+ ## O que ela faz
14
+
15
+ - Analisa contratos **OpenAPI 3.x** (YAML ou JSON)
16
+ - Detecta sinais de risco: tenant headers, parâmetros de data, enums, timezone livre
17
+ - Seleciona vetores OWASP API Security aplicáveis via taxonomia
18
+ - Gera um **design doc** em Markdown com:
19
+ - Procedimentos passo a passo por vetor
20
+ - Payloads e exemplos HTTP/SQL
21
+ - Tabela resumo (Acesso · Entrada · Disponibilidade · Informação)
22
+ - Recomendações imediatas de remediação
23
+ - Red flags do contrato
24
+
25
+ ## O que ela NÃO faz
26
+
27
+ - Scripts executáveis (Requests, Python, SQL runnable)
28
+ - Resultados de teste (APROVADO/REPROVADO)
29
+ - RFCs de implementação
30
+
31
+ Esses artefatos pertencem à **fase de execução** do pentest.
32
+
33
+ ## Instalação
34
+
35
+ ```bash
36
+ pip install security-pentest-planner
37
+ ```
38
+
39
+ Ou usando `uv` / `poetry`:
40
+
41
+ ```bash
42
+ uv add security-pentest-planner
43
+ # ou
44
+ poetry add security-pentest-planner
45
+ ```
46
+
47
+ ## Uso via CLI
48
+
49
+ ```bash
50
+ # Gerar plano no stdout
51
+ security-pentest-planner swagger/v2/swagger.json
52
+
53
+ # Salvar em arquivo
54
+ security-pentest-planner openapi.yaml -o plano-de-acao-pentest.md
55
+
56
+ # Com escopo e Data Lake
57
+ security-pentest-planner openapi.yaml \
58
+ --team "Platform Team" \
59
+ --scope /api/v1/metrics \
60
+ --datalake \
61
+ -o plano.md
62
+ ```
63
+
64
+ ### Opções
65
+
66
+ | Flag | Descrição |
67
+ |------|-----------|
68
+ | `-t, --team TEAM` | Nome do time no título |
69
+ | `-s, --scope PATH` | Limitar a um endpoint |
70
+ | `-d, --datalake` | Incluir vetores de Data Lake |
71
+ | `--api-layer NAME` | Nome da camada API (default: API) |
72
+ | `--data-layer NAME` | Nome da camada Data Lake (default: Data Lake) |
73
+ | `-o, --output FILE` | Salvar em arquivo |
74
+ | `-v, --version` | Exibe a versão |
75
+ | `-h, --help` | Exibe a ajuda |
76
+
77
+ ## Uso programático
78
+
79
+ ```python
80
+ import security_pentest_planner
81
+
82
+ # A partir de arquivo
83
+ plan = security_pentest_planner.generate(
84
+ input_path="openapi.yaml",
85
+ team="Platform Team",
86
+ scope="/api/v1/metrics",
87
+ include_datalake=True,
88
+ )
89
+
90
+ with open("plano-de-acao-pentest.md", "w", encoding="utf-8") as f:
91
+ f.write(plan)
92
+
93
+ # A partir de um dicionário (spec já carregada)
94
+ import yaml
95
+
96
+ with open("openapi.yaml", "r", encoding="utf-8") as f:
97
+ spec_data = yaml.safe_load(f)
98
+
99
+ plan = security_pentest_planner.generate_from_spec(
100
+ spec=spec_data,
101
+ team="Security Team",
102
+ )
103
+ ```
104
+
105
+ ## Publicar no PyPI
106
+
107
+ ```bash
108
+ python -m pip install build twine
109
+ python -m build
110
+ python -m twine upload dist/*
111
+ ```
112
+
113
+ ## Desenvolvimento e Testes
114
+
115
+ ```bash
116
+ git clone https://github.com/saulofilho/security-pentest-planner-python.git
117
+ cd security-pentest-planner-python
118
+
119
+ # Executar testes unitários
120
+ python3 -m unittest discover -s tests -v
121
+
122
+ # Ou com pytest
123
+ pytest -v
124
+ ```
125
+
126
+ ## Fluxo recomendado
127
+
128
+ ```
129
+ OpenAPI spec → security-pentest-planner → Plano de Ação (Markdown)
130
+
131
+ Execução manual / CI
132
+
133
+ Resultados + RFCs
134
+ ```
135
+
136
+ O pacote cobre a fase de **planejamento** de forma determinística — ideal para CI/CD, pipelines e integração em projetos Python/FastAPI/Django/Flask.
137
+
138
+ ## Licença
139
+
140
+ MIT — veja [LICENSE](LICENSE).
141
+
@@ -0,0 +1,39 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "security-pentest-planner"
7
+ version = "1.0.2"
8
+ description = "Generate pentest action plans from OpenAPI specifications"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ { name = "Saulo Filho", email = "saulofilho@users.noreply.github.com" }
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 5 - Production/Stable",
17
+ "Intended Audience :: Developers",
18
+ "Intended Audience :: Information Technology",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Security",
25
+ ]
26
+ dependencies = [
27
+ "pyyaml>=6.0",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://saulofilho.github.io/security-pentest-planner/"
32
+ Repository = "https://github.com/saulofilho/security-pentest-planner-python"
33
+
34
+ [project.scripts]
35
+ security-pentest-planner = "security_pentest_planner.cli:main"
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
39
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ from setuptools import setup
2
+
3
+ setup()
4
+
@@ -0,0 +1,48 @@
1
+ """security_pentest_planner package.
2
+
3
+ Gera Planos de Ação de Pentest a partir de especificações OpenAPI/Swagger.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import Any
9
+
10
+ from .contract_analyzer import ContractAnalyzer
11
+ from .errors import Error, InputError, ParseError
12
+ from .models import Category, Endpoint, Parameter, RedFlag, Vector
13
+ from .openapi_parser import OpenAPIParser
14
+ from .plan_renderer import PlanRenderer
15
+ from .planner import Planner
16
+ from .vector_catalog import VectorCatalog
17
+ from .version import __version__
18
+
19
+
20
+ def generate(input_path: str, **options: Any) -> str:
21
+ """Generate a pentest action plan from an OpenAPI specification file."""
22
+ return Planner(input_path=input_path, **options).call()
23
+
24
+
25
+ def generate_from_spec(spec: dict[str, Any], **options: Any) -> str:
26
+ """Generate a pentest action plan from an in-memory OpenAPI specification dict."""
27
+ return Planner(spec=spec, **options).call()
28
+
29
+
30
+ __all__ = [
31
+ "__version__",
32
+ "generate",
33
+ "generate_from_spec",
34
+ "Planner",
35
+ "OpenAPIParser",
36
+ "ContractAnalyzer",
37
+ "VectorCatalog",
38
+ "PlanRenderer",
39
+ "Endpoint",
40
+ "Parameter",
41
+ "RedFlag",
42
+ "Vector",
43
+ "Category",
44
+ "Error",
45
+ "ParseError",
46
+ "InputError",
47
+ ]
48
+
@@ -0,0 +1,8 @@
1
+ """Main entry point when invoked as python -m security_pentest_planner."""
2
+
3
+ import sys
4
+ from .cli import main
5
+
6
+ if __name__ == "__main__":
7
+ sys.exit(main())
8
+
@@ -0,0 +1,65 @@
1
+ """CLI entry point for security-pentest-planner."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import sys
7
+ from pathlib import Path
8
+ from typing import Sequence
9
+
10
+ from .errors import Error
11
+ from .planner import Planner
12
+ from .version import __version__
13
+
14
+
15
+ def build_parser() -> argparse.ArgumentParser:
16
+ """Builds the argument parser for the CLI."""
17
+ parser = argparse.ArgumentParser(
18
+ prog="security-pentest-planner",
19
+ description="Gera um Plano de Ação de Pentest a partir de especificação OpenAPI.",
20
+ )
21
+ parser.add_argument("input", nargs="?", help="Caminho do arquivo OpenAPI (.yaml, .yml, .json)")
22
+ parser.add_argument("-t", "--team", help="Nome do time no título do documento")
23
+ parser.add_argument("-s", "--scope", help="Limitar escopo a um path (ex: /api/v1/metrics)")
24
+ parser.add_argument("-d", "--datalake", action="store_true", help="Incluir vetores de Data Lake no plano")
25
+ parser.add_argument("--api-layer", default="API", help="Nome da camada de API no documento (default: API)")
26
+ parser.add_argument("--data-layer", default="Data Lake", help="Nome da camada de Data Lake no documento (default: Data Lake)")
27
+ parser.add_argument("-o", "--output", help="Salvar plano em arquivo (default: stdout)")
28
+ parser.add_argument("-v", "--version", action="version", version=f"security_pentest_planner {__version__}")
29
+ return parser
30
+
31
+
32
+ def main(argv: Sequence[str] | None = None) -> int:
33
+ """Main CLI execution method."""
34
+ parser = build_parser()
35
+ args = parser.parse_args(argv)
36
+
37
+ if not args.input:
38
+ parser.print_help(sys.stderr)
39
+ return 1
40
+
41
+ try:
42
+ planner = Planner(
43
+ input_path=args.input,
44
+ team=args.team,
45
+ scope=args.scope,
46
+ include_datalake=args.datalake,
47
+ api_layer=args.api_layer,
48
+ data_layer=args.data_layer,
49
+ )
50
+ plan = planner.call()
51
+
52
+ if args.output:
53
+ Path(args.output).write_text(plan, encoding="utf-8")
54
+ print(f"Plano de Ação gerado em {args.output}", file=sys.stderr)
55
+ else:
56
+ print(plan)
57
+ return 0
58
+ except Error as e:
59
+ print(f"Erro: {e}", file=sys.stderr)
60
+ return 1
61
+
62
+
63
+ if __name__ == "__main__":
64
+ sys.exit(main())
65
+