Skip to content

Commit

Permalink
Fix pdflatex crash when there are underscores (1.7) (#691)
Browse files Browse the repository at this point in the history
  • Loading branch information
dekkers authored Apr 7, 2023
1 parent 52599cb commit f33e2c0
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 356 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/keiko_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
python-version: ${{ matrix.version }}
cache: 'pip' # caching pip dependencies

- name: Install Latex
run: sudo apt-get install -y --no-install-recommends texlive-latex-base texlive-latex-extra texlive-latex-recommended texlive-lang-european texlive-fonts-recommended

- name: Install requirements-dev.txt
run: pip install -r requirements-dev.txt
working-directory: ./keiko
Expand Down
5 changes: 2 additions & 3 deletions keiko/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ check-latex:
done

test:
python -m unittest discover -s tests -p "test_*.py"
pytest

itest:
docker-compose -f docker-compose-base.yml -f .ci/docker-compose.yml up -d --build
Expand Down Expand Up @@ -75,5 +75,4 @@ clean:

export-requirements: ## Export the requirements to requirements.txt
poetry export --output requirements.txt --without-hashes && \
poetry export --output requirements-dev.txt --with dev --without-hashes && \
poetry export --output requirements-check.txt --only dev --without-hashes
poetry export --output requirements-dev.txt --with dev --without-hashes
336 changes: 55 additions & 281 deletions keiko/poetry.lock

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions keiko/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
description = "KAT report engine using LateX to generate PDF"
authors = ["MinVWS <[email protected]>"]
license = "EUPL"
[tool.poetry.group.dev.dependencies]
pytest = "^7.2.2"


[tool.vulture]
min_confidence = 90
Expand Down Expand Up @@ -31,16 +34,14 @@ python = "^3.8"
click = "^8.1.3"
pydantic = "^1.9.2"
Jinja2 = "^3.1.2"
fastapi = "^0.79.1"
uvicorn = "^0.18.2"
fastapi = "^0.85.2"
uvicorn = "^0.19.0"
vulture = "^2.5"

[tool.poetry.dev-dependencies]
black = "^22.6.0"
mypy = "^0.971"
pylint = "^2.14.5"
pytest = "^7.2.2"
robotframework-tidy = "^3.2"
robotframework = "^5.0.1"
robotframework = "^6.0.1"
robotframework-debuglibrary = "^2.3.0"
robotframework-requests = "^0.9.3"

Expand Down
33 changes: 0 additions & 33 deletions keiko/requirements-check.txt

This file was deleted.

26 changes: 11 additions & 15 deletions keiko/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
anyio==3.6.2 ; python_version >= "3.8" and python_version < "4.0"
astroid==2.12.12 ; python_version >= "3.8" and python_version < "4.0"
black==22.10.0 ; python_version >= "3.8" and python_version < "4.0"
certifi==2022.9.24 ; python_version >= "3.8" and python_version < "4"
attrs==22.2.0 ; python_version >= "3.8" and python_version < "4.0"
certifi==2022.12.7 ; python_version >= "3.8" and python_version < "4"
charset-normalizer==2.1.1 ; python_version >= "3.8" and python_version < "4"
click==8.1.3 ; python_version >= "3.8" and python_version < "4.0"
colorama==0.4.6 ; python_version >= "3.8" and python_version < "4.0"
commonmark==0.9.1 ; python_version >= "3.8" and python_version < "4.0"
dill==0.3.6 ; python_version >= "3.8" and python_version < "4.0"
exceptiongroup==1.1.1 ; python_version >= "3.8" and python_version < "3.11"
fastapi==0.85.2 ; python_version >= "3.8" and python_version < "4.0"
h11==0.14.0 ; python_version >= "3.8" and python_version < "4.0"
idna==3.4 ; python_version >= "3.8" and python_version < "4"
isort==5.10.1 ; python_version >= "3.8" and python_version < "4.0"
iniconfig==2.0.0 ; python_version >= "3.8" and python_version < "4.0"
jinja2==3.1.2 ; python_version >= "3.8" and python_version < "4.0"
lazy-object-proxy==1.8.0 ; python_version >= "3.8" and python_version < "4.0"
markupsafe==2.1.1 ; python_version >= "3.8" and python_version < "4.0"
mccabe==0.7.0 ; python_version >= "3.8" and python_version < "4.0"
mypy-extensions==0.4.3 ; python_version >= "3.8" and python_version < "4.0"
mypy==0.982 ; python_version >= "3.8" and python_version < "4.0"
packaging==23.0 ; python_version >= "3.8" and python_version < "4.0"
pathspec==0.9.0 ; python_version >= "3.8" and python_version < "4.0"
platformdirs==2.5.2 ; python_version >= "3.8" and python_version < "4.0"
pycodestyle==2.9.1 ; python_version >= "3.8" and python_version < "4.0"
pluggy==1.0.0 ; python_version >= "3.8" and python_version < "4.0"
prompt-toolkit==2.0.10 ; python_version >= "3.8" and python_version < "4.0"
pydantic==1.10.2 ; python_version >= "3.8" and python_version < "4.0"
pyflakes==2.5.0 ; python_version >= "3.8" and python_version < "4.0"
pygments==2.13.0 ; python_version >= "3.8" and python_version < "4.0"
pylint==2.15.5 ; python_version >= "3.8" and python_version < "4.0"
pytest==7.2.2 ; python_version >= "3.8" and python_version < "4.0"
requests==2.28.1 ; python_version >= "3.8" and python_version < "4"
rich-click==1.4 ; python_version >= "3.8" and python_version < "4.0"
rich==12.6.0 ; python_version >= "3.8" and python_version < "4.0"
robotframework-debuglibrary==2.3.0 ; python_version >= "3.8" and python_version < "4.0"
robotframework-requests==0.9.4 ; python_version >= "3.8" and python_version < "4.0"
robotframework-tidy==3.3.2 ; python_version >= "3.8" and python_version < "4.0"
robotframework==6.0.1 ; python_version >= "3.8" and python_version < "4.0"
six==1.16.0 ; python_version >= "3.8" and python_version < "4.0"
sniffio==1.3.0 ; python_version >= "3.8" and python_version < "4.0"
starlette==0.20.4 ; python_version >= "3.8" and python_version < "4.0"
toml==0.10.2 ; python_version >= "3.8" and python_version < "4.0"
tomli==2.0.1 ; python_version >= "3.8" and python_version < "4.0"
tomlkit==0.11.6 ; python_version >= "3.8" and python_version < "4.0"
typing-extensions==4.4.0 ; python_version >= "3.8" and python_version < "4.0"
urllib3==1.26.12 ; python_version >= "3.8" and python_version < "4"
uvicorn==0.19.0 ; python_version >= "3.8" and python_version < "4.0"
vulture==2.6 ; python_version >= "3.8" and python_version < "4.0"
wrapt==1.14.1 ; python_version >= "3.8" and python_version < "4.0"
wcwidth==0.2.6 ; python_version >= "3.8" and python_version < "4.0"
2 changes: 2 additions & 0 deletions keiko/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ markupsafe==2.1.1 ; python_version >= "3.8" and python_version < "4.0"
pydantic==1.10.2 ; python_version >= "3.8" and python_version < "4.0"
sniffio==1.3.0 ; python_version >= "3.8" and python_version < "4.0"
starlette==0.20.4 ; python_version >= "3.8" and python_version < "4.0"
toml==0.10.2 ; python_version >= "3.8" and python_version < "4.0"
typing-extensions==4.4.0 ; python_version >= "3.8" and python_version < "4.0"
uvicorn==0.19.0 ; python_version >= "3.8" and python_version < "4.0"
vulture==2.6 ; python_version >= "3.8" and python_version < "4.0"
26 changes: 13 additions & 13 deletions keiko/templates/bevindingenrapport/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
\usepackage{ragged2e}
\usepackage{titlepic}
\usepackage{xcolor}

\usepackage{underscore}

\hypersetup{
colorlinks=true,
Expand All @@ -22,17 +22,17 @@
pdftitle={KEIKO Document by KAT},
}

\definecolor{box_color_critical}{HTML}{42145F}
\definecolor{box_color_high}{HTML}{D6293E}
\definecolor{box_color_medium}{HTML}{C36100}
\definecolor{box_color_low}{HTML}{00519C}
\definecolor{box_color_recommendation}{HTML}{C3DDF6}
\definecolor{box-color-critical}{HTML}{42145F}
\definecolor{box-color-high}{HTML}{D6293E}
\definecolor{box-color-medium}{HTML}{C36100}
\definecolor{box-color-low}{HTML}{00519C}
\definecolor{box-color-recommendation}{HTML}{C3DDF6}

\definecolor{color_critical}{HTML}{FFFFFF}
\definecolor{color_high}{HTML}{FFFFFF}
\definecolor{color_medium}{HTML}{FFFFFF}
\definecolor{color_low}{HTML}{FFFFFF}
\definecolor{color_recommendation}{HTML}{000000}
\definecolor{color-critical}{HTML}{FFFFFF}
\definecolor{color-high}{HTML}{FFFFFF}
\definecolor{color-medium}{HTML}{FFFFFF}
\definecolor{color-low}{HTML}{FFFFFF}
\definecolor{color-recommendation}{HTML}{000000}

%KEIKO-specific variables
\newcommand\application{KEIKO @@{keiko_version}@@}
Expand Down Expand Up @@ -117,7 +117,7 @@ \section{Totalen}
Niveau & Uniek & Totaal aantal voorvallen \\\toprule
\toprule
{% for level_name, level_sum in meta.total_by_severity.items() %}
\colorbox{box_color_@@{ level_name }@@}{ \color{color_@@{ level_name }@@} @@{ level_name }@@ } & @@{ meta.total_by_severity_per_finding_type[level_name] }@@ & @@{ level_sum }@@ \\
\colorbox{box-color-@@{ level_name }@@}{ \color{color-@@{ level_name }@@} @@{ level_name }@@ } & @@{ meta.total_by_severity_per_finding_type[level_name] }@@ & @@{ level_sum }@@ \\
{% endfor %}
\bottomrule
Totaal & @@{meta.total_finding_types}@@ & @@{meta.total}@@
Expand All @@ -131,7 +131,7 @@ \section{Bevinding types}
Risico niveau & Bevindingstype & Voorvallen \\\toprule
\midrule
{% for finding_type_id, occurrence in findings_grouped.items()|sort(attribute='1.finding_type.risk_level_score', reverse=True) %}
\colorbox{box_color_@@{ occurrence.finding_type.risk_level_severity }@@}{ \color{color_@@{ occurrence.finding_type.risk_level_severity }@@} @@{ occurrence.finding_type.risk_level_severity }@@ } & @@{ occurrence.finding_type.id }@@ & @@{occurrence.list|length}@@ \\
\colorbox{box-color-@@{ occurrence.finding_type.risk_level_severity }@@}{ \color{color-@@{ occurrence.finding_type.risk_level_severity }@@} @@{ occurrence.finding_type.risk_level_severity }@@ } & @@{ occurrence.finding_type.id }@@ & @@{occurrence.list|length}@@ \\
{% endfor %}
\bottomrule
\end{tabular}
Expand Down
2 changes: 1 addition & 1 deletion keiko/templates/dns/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
\usepackage{ragged2e}
\usepackage{titlepic}
\usepackage{xcolor}

\usepackage{underscore}

\hypersetup{
colorlinks=true,
Expand Down
2 changes: 1 addition & 1 deletion keiko/templates/intel/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
\usepackage{ragged2e}
\usepackage{titlepic}
\usepackage{xcolor}

\usepackage{underscore}

\hypersetup{
colorlinks=true,
Expand Down
8 changes: 5 additions & 3 deletions keiko/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ class APITest(TestCase):
maxDiff = None

def setUp(self) -> None:
fixtures = Path(__file__).parent / "fixtures"

keiko.templates.settings.templates_folder = str(fixtures / "templates")
self.orig_templates_folder = keiko.templates.settings.templates_folder
keiko.templates.settings.templates_folder = Path(__file__).parent / "fixtures" / "templates"

self.api = construct_api()
self.client = TestClient(self.api)

def tearDown(self):
keiko.templates.settings.templates_folder = self.orig_templates_folder

def test_health(self):
response = self.client.get("/health")

Expand Down
4 changes: 4 additions & 0 deletions keiko/tests/test_glossary.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
class KeikoGlossaryTest(TestCase):
def setUp(self) -> None:
self.maxDiff = None
self.orig_glossaries_folder = settings.glossaries_folder
settings.glossaries_folder = Path(__file__).parent / "fixtures" / "glossaries"

def tearDown(self) -> None:
settings.glossaries_folder = self.orig_glossaries_folder

def test_read_glossary(self):
glossary_entries = read_glossary("test_glossary.csv")
self.assertEqual({"meow": ("Meow", "The sound a cat makes when hungry")}, glossary_entries)
Loading

0 comments on commit f33e2c0

Please sign in to comment.