Skip to content

Add test core extraction #941

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

Merged
merged 1 commit into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,12 @@ def test_core_uninstall(run_command):
result = run_command("core list --format json")
assert result.ok
assert not _in(result.stdout, "arduino:avr")


def test_core_zipslip(run_command):
url = "https://raw.githubusercontent.com/arduino/arduino-cli/master/test/testdata/test_index.json"
assert run_command("core update-index --additional-urls={}".format(url))

# Install a core and check if malicious content has been extracted.
run_command("core install zipslip:x86 --additional-urls={}".format(url))
assert os.path.exists("/tmp/evil.txt") is False
Binary file added test/testdata/evil.zip
Binary file not shown.
31 changes: 31 additions & 0 deletions test/testdata/test_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,37 @@
"tools": [],
"email": "[email protected]",
"name": "test"
},
{
"name": "zipslip",
"tools": [],
"email": "[email protected]",
"maintainer": "Arduino",
"help": {
"online": "https://github.com/Arduino/arduino-cli"
},
"websiteURL": "https://github.com/Arduino/arduino-cli",
"platforms": [
{
"category": "Zipslip Test",
"help": {
"online": "https://github.com/Arduino/arduino-cli"
},
"url": "https://raw.githubusercontent.com/arduino/arduino-cli/master/test/testdata/evil.zip",
"checksum": "SHA-256:9b85dfe23f13318efc0e541327f584a0f3674a773d46a7eb8b25f0f408d07f96",
"name": "zipslip",
"version": "1.0.0",
"architecture": "x86",
"archiveFileName": "evil.zip",
"size": "2184",
"toolsDependencies": [],
"boards": [
{
"name": "Test Board"
}
]
}
]
}
]
}