|
15 | 15 | import sys
|
16 | 16 | from unittest import TestCase
|
17 | 17 | import zipfile
|
| 18 | +import pip |
18 | 19 |
|
19 | 20 | from picklescan.cli import main
|
20 | 21 | from picklescan.scanner import (
|
@@ -100,6 +101,11 @@ def __reduce__(self):
|
100 | 101 | 'import os\nos.system("whoami")',
|
101 | 102 | )
|
102 | 103 |
|
| 104 | +class Malicious16: |
| 105 | + def __reduce__(self): |
| 106 | + return pip.main, ( |
| 107 | + ['install', 'some_malicious_package', '--no-input', '-q', '-q', '-q', |
| 108 | + '--exists-action', 'i', '--isolated'],) |
103 | 109 |
|
104 | 110 | class HTTPResponse:
|
105 | 111 | def __init__(self, status, data=None):
|
@@ -412,6 +418,7 @@ def initialize_pickle_files():
|
412 | 418 | ) # runpy
|
413 | 419 | initialize_pickle_file(f"{_root_path}/data/malicious15a.pkl", Malicious15(), 2)
|
414 | 420 | initialize_pickle_file(f"{_root_path}/data/malicious15b.pkl", Malicious15(), 4)
|
| 421 | + initialize_pickle_file(f"{_root_path}/data/malicious16.pkl", Malicious16(), 0) |
415 | 422 |
|
416 | 423 | initialize_7z_file(
|
417 | 424 | f"{_root_path}/data/malicious1.7z",
|
@@ -752,10 +759,11 @@ def test_scan_directory_path():
|
752 | 759 | Global("bdb", "Bdb.run", SafetyLevel.Dangerous),
|
753 | 760 | Global("builtins", "exec", SafetyLevel.Dangerous),
|
754 | 761 | Global("builtins", "eval", SafetyLevel.Dangerous),
|
| 762 | + Global("pip", "main", SafetyLevel.Dangerous), |
755 | 763 | ],
|
756 |
| - scanned_files=32, |
757 |
| - issues_count=32, |
758 |
| - infected_files=27, |
| 764 | + scanned_files=33, |
| 765 | + issues_count=33, |
| 766 | + infected_files=28, |
759 | 767 | scan_err=True,
|
760 | 768 | )
|
761 | 769 | compare_scan_results(scan_directory_path(f"{_root_path}/data/"), sr)
|
|
0 commit comments