Skip to content

Commit 042eaa8

Browse files
Merge branch 'enhance-2.2-prs' into 'master'
Enhancement: Incorporating PRs GhostManager#143, GhostManager#152, and GhostManager#158 See merge request ghostmanager/Ghostwriter!114
2 parents 8044978 + 2b67250 commit 042eaa8

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

DOCS/sample_reports/template.docx

668 Bytes
Binary file not shown.

compose/local/django/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ RUN chmod +x /seed_data
4747

4848
WORKDIR /app
4949

50+
RUN mkdir -p /app/ghostwriter/media
51+
5052
VOLUME ["/app/ghostwriter/media"]
5153

5254
ENTRYPOINT ["/entrypoint"]

compose/production/django/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ RUN chmod +x /seed_data
5151

5252
RUN mkdir -p /app/staticfiles
5353

54+
RUN mkdir -p /app/ghostwriter/media
55+
5456
RUN chown -R django /app
5557

5658
USER django

ghostwriter/modules/reportwriter.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,25 @@ def filter_severity(findings, allowlist):
6565
return filtered_values
6666

6767

68+
def filter_type(findings, allowlist):
69+
"""
70+
Filter list of findings to return only those with a type in the allowlist.
71+
72+
**Parameters**
73+
74+
``findings``
75+
List of dictionary objects (JSON) for findings
76+
``allowlist``
77+
List of strings matching severity categories to allow through filter
78+
"""
79+
filtered_values = []
80+
allowlist = [type.lower() for type in allowlist]
81+
for finding in findings:
82+
if finding["finding_type"].lower() in allowlist:
83+
filtered_values.append(finding)
84+
return filtered_values
85+
86+
6887
def strip_html(s):
6988
"""
7089
Strip HTML tags from the provided HTML while preserving newlines created by
@@ -110,6 +129,7 @@ def prepare_jinja2_env(debug=False):
110129

111130
env = jinja2.Environment(undefined=undefined, extensions=["jinja2.ext.debug"])
112131
env.filters["filter_severity"] = filter_severity
132+
env.filters["filter_type"] = filter_type
113133
env.filters["strip_html"] = strip_html
114134
env.filters["compromised"] = compromised
115135

@@ -1199,10 +1219,10 @@ def process_text_xml(self, text, finding=None):
11991219
"""
12001220
prev_p = None
12011221

1202-
# Clean text to make it XML compatible for Office XML
1203-
text = "".join(c for c in text if self.valid_xml_char_ordinal(c))
1204-
12051222
if text:
1223+
# Clean text to make it XML compatible for Office XML
1224+
text = "".join(c for c in text if self.valid_xml_char_ordinal(c))
1225+
12061226
# Parse the HTML into a BS4 soup object
12071227
soup = BeautifulSoup(text, "lxml")
12081228

0 commit comments

Comments
 (0)