Skip to content

Commit 1e5354b

Browse files
author
Federico
authored
[skip-changelog] Added tests for core extraction (#941)
1 parent 9d7041e commit 1e5354b

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

Diff for: test/test_core.py

+9
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,12 @@ def test_core_uninstall(run_command):
194194
result = run_command("core list --format json")
195195
assert result.ok
196196
assert not _in(result.stdout, "arduino:avr")
197+
198+
199+
def test_core_zipslip(run_command):
200+
url = "https://raw.githubusercontent.com/arduino/arduino-cli/master/test/testdata/test_index.json"
201+
assert run_command("core update-index --additional-urls={}".format(url))
202+
203+
# Install a core and check if malicious content has been extracted.
204+
run_command("core install zipslip:x86 --additional-urls={}".format(url))
205+
assert os.path.exists("/tmp/evil.txt") is False

Diff for: test/testdata/evil.zip

2.13 KB
Binary file not shown.

Diff for: test/testdata/test_index.json

+31
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,37 @@
4949
"tools": [],
5050
"email": "[email protected]",
5151
"name": "test"
52+
},
53+
{
54+
"name": "zipslip",
55+
"tools": [],
56+
"email": "[email protected]",
57+
"maintainer": "Arduino",
58+
"help": {
59+
"online": "https://github.com/Arduino/arduino-cli"
60+
},
61+
"websiteURL": "https://github.com/Arduino/arduino-cli",
62+
"platforms": [
63+
{
64+
"category": "Zipslip Test",
65+
"help": {
66+
"online": "https://github.com/Arduino/arduino-cli"
67+
},
68+
"url": "https://raw.githubusercontent.com/arduino/arduino-cli/master/test/testdata/evil.zip",
69+
"checksum": "SHA-256:9b85dfe23f13318efc0e541327f584a0f3674a773d46a7eb8b25f0f408d07f96",
70+
"name": "zipslip",
71+
"version": "1.0.0",
72+
"architecture": "x86",
73+
"archiveFileName": "evil.zip",
74+
"size": "2184",
75+
"toolsDependencies": [],
76+
"boards": [
77+
{
78+
"name": "Test Board"
79+
}
80+
]
81+
}
82+
]
5283
}
5384
]
5485
}

0 commit comments

Comments
 (0)