Mirrored from https://github.com/davoodmehraban89/Aram.git
Synced Dec 3, 19:30 UTC
test(integration): include veryHidden XLSX security regressions
davoodmehraban89 committed
Oct 30, 2026 at 17:41 UTC
31e9fd71f928b81b39b645089104e4659f317f6e
1 file changed
+8
-5
backend/tests/test_mapping_excel.py
+8
-5
@@ -160,11 +160,13 @@ def workbook_with_hidden_mapping(kind, note_id=1):
160
sheet.column_dimensions["B"].hidden = True
161
elif kind == "last_column":
162
sheet.column_dimensions["E"].hidden = True
163
- elif kind != "sheet":
163
+ elif kind == "range":
164
+ sheet.column_dimensions.group("B", "D", hidden=True)
165
+ elif kind not in ("sheet", "veryHidden"):
166
raise AssertionError("unknown test variant")
167
stream = BytesIO()
168
book.save(stream)
167
- if kind != "sheet":
169
+ if kind not in ("sheet", "veryHidden"):
170
return stream.getvalue()
171
172
# Excel/openpyxl forbids saving a workbook with its *only* sheet hidden.
@@ -177,18 +179,19 @@ def workbook_with_hidden_mapping(kind, note_id=1):
179
content = source.read(item.filename)
180
if item.filename == "xl/workbook.xml":
181
assert b'state="visible"' in content
180
- content = content.replace(b'state="visible"', b'state="hidden"', 1)
182
+ new_state = b'state="veryHidden"' if kind == "veryHidden" else b'state="hidden"'
183
+ content = content.replace(b'state="visible"', new_state, 1)
184
dest.writestr(item, content)
185
return altered.getvalue()
186
187
185
-@pytest.mark.parametrize("kind", ["sheet", "row", "header", "column", "last_column"])
188
+@pytest.mark.parametrize("kind", ["sheet", "veryHidden", "row", "header", "column", "last_column", "range"])
189
def test_reject_hidden_mapping_sheet_or_data(kind):
190
with pytest.raises(MappingValidationError, match="[Hh]idden"):
191
preview_mapping_workbook(workbook_with_hidden_mapping(kind))
192
193
191
-@pytest.mark.parametrize("kind", ["sheet", "row", "column"])
194
+@pytest.mark.parametrize("kind", ["sheet", "veryHidden", "row", "column"])
195
def test_hidden_mapping_import_never_stages_rules(session, kind):
196
year, note = make_year(session, "HIDDEN-" + kind)
197
content = workbook_with_hidden_mapping(kind, note.id)