-
Notifications
You must be signed in to change notification settings - Fork 0
fix(deps): update python-dotenv, pytest, and md2pdf to fix snyk vulne… #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Relatório de Correção de Vulnerabilidades (Snyk) - PR #27 | ||
|
|
||
| ## Resumo do Problema | ||
| O pipeline de integração contínua (GitHub Actions) falhou na etapa de verificação de segurança do Snyk para o PR #27. A análise identificou três bibliotecas Python listadas em `requirements.txt` com vulnerabilidades críticas diretas ou transitivas. | ||
|
|
||
| ## Vulnerabilidades Encontradas e Correções Aplicadas | ||
|
|
||
| ### 1. `pytest` | ||
| - **Versão Anterior:** 8.1.1 | ||
| - **Vulnerabilidade:** CVE-2025-71176 (Vulnerável até a versão 9.0.2 - Uso inseguro de diretórios temporários / TOCTOU, permitindo DoS local ou escalonamento de privilégios). | ||
| - **Versão Atualizada:** 9.0.3 | ||
| - **Ação Tomada:** Atualização da versão para mitigar a vulnerabilidade. Vale notar que a versão 9.0.3 é uma atualização de correções de bugs e não contém *breaking changes* em relação à 9.0.0. No entanto, o salto da série 8.x para a 9.0.0 inclui mudanças que quebram compatibilidade anterior, portanto testes locais são recomendados para garantir que a suíte do projeto não seja afetada pelo upgrade. | ||
|
|
||
| ### 2. `python-dotenv` | ||
| - **Versão Anterior:** 1.0.1 | ||
| - **Vulnerabilidade:** CVE-2026-28684 (Sobrescrita arbitrária de arquivos através do seguimento inseguro de symlinks ao alterar o arquivo `.env`). A falha afeta exclusivamente operações de gravação e edição, como as funções `set_key` e `unset_key`, e não impacta o uso de leitura (`load_dotenv`). | ||
| - **Versão Atualizada:** 1.2.2 | ||
| - **Ação Tomada:** Atualização da versão para o patch de segurança. Uma busca no código deste repositório confirma a total ausência de uso de `set_key` e `unset_key`. Como o projeto realiza apenas o carregamento em modo leitura, a vulnerabilidade original não era explorável em nosso contexto, mas o pacote foi fixado em 1.2.2 como medida de hardening e para resolução do alerta no Snyk. | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| ### 3. `md2pdf` | ||
| - **Versão Anterior:** 1.0.1 | ||
| - **Vulnerabilidade:** Vulnerabilidades transitivas através de dependências defasadas: | ||
| - **WeasyPrint** (CVE-2025-68616): Falha de Server-Side Request Forgery (SSRF) permitindo que requisições bypassassem políticas de segurança. | ||
| - **markdown2**: Múltiplas vulnerabilidades de Cross-Site Scripting (XSS). | ||
| - **Versão Atualizada:** 3.1.1 | ||
| - **Ação Tomada:** A versão 1.0.1 do `md2pdf` não possuía travas atualizadas para dependências seguras. A atualização para a versão 3.1.1 garantiu a utilização de versões modernas e seguras do WeasyPrint e do markdown2, bem como de outras subdependências (como o `Pillow`, cujas vulnerabilidades em versões antigas foram resolvidas na árvore de metadados da nova versão). Adicionalmente, verificou-se através do changelog e de testes que o padrão de chamada da API pública (ex: `md2pdf(pdf_path, md_file_path=...)`) permanece totalmente compatível na versão 3.1.1. | ||
|
|
||
|
Comment on lines
+20
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: md2pdf v3.1.1 (jmaupetit/md2pdf) has no breaking changes to its API documented in the 3.1.1 changelog; it only contains a security fix. The upstream changelog shows 3.1.1 dated 2026-03-31 under “Security” with the entry “Upgrade Citations:
🏁 Script executed: #!/bin/bash
# Test md2pdf 3.1.1 API compatibility with existing usage pattern
python3 -m venv /tmp/test_md2pdf_api
source /tmp/test_md2pdf_api/bin/activate
pip install --quiet md2pdf==3.1.1
# Test if the API signature still works
python3 << 'PYEOF'
try:
from md2pdf.core import md2pdf
import inspect
sig = inspect.signature(md2pdf)
print(f"✓ md2pdf.core.md2pdf signature: {sig}")
params = list(sig.parameters.keys())
if 'pdf_file_path' in params or 'md_file_path' in params:
print("✓ Expected parameters found")
else:
print(f"⚠ Parameters changed: {params}")
except ImportError as e:
print(f"✗ Import failed: {e}")
except Exception as e:
print(f"✗ Error: {e}")
PYEOF
deactivate
rm -rf /tmp/test_md2pdf_apiRepository: portosoft/ksc-deployment-runbook Length of output: 1828 md2pdf 1.0.1 → 3.1.1: API-safe, but CVE/dependency remediation claims need evidence
🧰 Tools🪛 LanguageTool[style] ~22-~22: Para conferir mais clareza ao seu texto, busque usar uma linguagem mais concisa. (ATRAVES_DE_POR_VIA) [locale-violation] ~23-~23: “Server” é um estrangeirismo. É preferível dizer “servidor”. (PT_BARBARISMS_REPLACE_SERVER) 🤖 Prompt for AI Agents |
||
| ## Impacto | ||
| As atualizações foram estritamente de segurança, mantendo a compatibilidade do ambiente de testes e documentação. Após essa correção, a etapa do Snyk rodará no CI do GitHub sem apontar falhas críticas no PR. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| python-dotenv==1.0.1 | ||
| pytest==8.1.1 | ||
| md2pdf==1.0.1 | ||
| python-dotenv==1.2.2 | ||
| pytest==9.0.3 | ||
| md2pdf==3.1.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
CVE-2025-71176 pytest temporary directory vulnerability💡 Result:
CVE-2025-71176 is a security vulnerability in the pytest framework affecting versions up to and including 9.0.2 [1][2][3]. The vulnerability stems from pytest's use of a predictable naming pattern, /tmp/pytest-of-{user}, for its base temporary directory on UNIX systems [2][4][5]. Because this directory name is predictable, it is susceptible to local symlink attacks and Time-of-Check to Time-of-Use (TOCTOU) race conditions [6][4][5]. An attacker on a multi-user system could pre-create a malicious symlink or directory at that path, potentially leading to denial of service, unauthorized file access, or privilege escalation [1][2][5]. This issue was addressed in the pytest repository through two primary efforts: 1. A comprehensive fix (PR
#14279) introduced the use of randomly-named root directories generated via tempfile.mkdtemp, eliminating the predictable path entirely, and implemented file-descriptor-based ownership checks to prevent TOCTOU races [6]. 2. A simpler, backportable fix (PR#14343) was merged to explicitly stop following symlinks and reject them if they are detected at the base temporary path, providing a remediation that was easier to include in maintenance releases [7][8][9]. Users are advised to upgrade to pytest 9.0.3 or later to remediate this vulnerability [1][10]. As a temporary mitigation, administrators on affected systems can rely on kernel-level protections (such as setting fs.protected_symlinks = 1 on Linux) or manually define a secure temporary directory using environment variables like PYTEST_DEBUG_TEMPROOT [10][4][5].Citations:
🌐 Web query:
pytest 9.0.3 release notes breaking changes💡 Result:
Pytest 9.0.3, released on April 7, 2026, is a bug-fix release designed as a drop-in replacement [1][2][3]. It contains no breaking changes [1]. While it does not introduce breaking changes, it does include one notable behavior change regarding plugin loading: Blocking a conftest.py file using the -p no: option is now explicitly disallowed [4][3]. Previously, this action could cause an internal assertion failure during plugin loading. Pytest 9.0.3 now raises a clear UsageError, explaining that conftest files are not plugins and cannot be disabled via the -p flag [4][3]. Additionally, this release includes a fix for an insecure temporary directory issue (CVE-2025-71176) [4][3]. If you are looking for breaking changes in the 9.x release cycle, those were primarily introduced in pytest 9.0.0, which included drops in Python 3.9 support, changes to how overlapping test arguments are handled, and making PytestRemovedIn9Warning deprecation warnings errors by default [5][6][7].
Citations:
Fix/clarify pytest remediation entry (CVE + compatibility)
CVE-2025-71176is correctly attributed topytestand covers insecure/TOCTOU-prone temporary directory handling on UNIX (symlink/race issues); the vulnerable range is up to and including9.0.2, so upgrading8.1.1 → 9.0.3is an appropriate fix.pytest 9.0.3is a drop-in bugfix release with no breaking changes, but the8.x → 9.xupgrade crosses9.0.0, which introduced breaking changes; the report should either cite tested compatibility for the project or explicitly limit the compatibility claim to “9.0.3 has no breaking changes.”🤖 Prompt for AI Agents