Skip to content

Commit 78ce704

Browse files
authored
Merge commit from fork
1 parent 25d753f commit 78ce704

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

src/picklescan/scanner.py

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def __str__(self) -> str:
130130
"bdb": "*",
131131
"pdb": "*",
132132
"asyncio": "*",
133+
"pip": "*",
133134
}
134135

135136
#

tests/data/malicious16.pkl

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
cpip
2+
main
3+
p0
4+
((lp1
5+
Vinstall
6+
p2
7+
aVsome_malicious_package
8+
p3
9+
aV--no-input
10+
p4
11+
aV-q
12+
p5
13+
ag5
14+
ag5
15+
aV--exists-action
16+
p6
17+
aVi
18+
p7
19+
aV--isolated
20+
p8
21+
atp9
22+
Rp10
23+
.

tests/test_scanner.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import sys
1616
from unittest import TestCase
1717
import zipfile
18+
import pip
1819

1920
from picklescan.cli import main
2021
from picklescan.scanner import (
@@ -100,6 +101,11 @@ def __reduce__(self):
100101
'import os\nos.system("whoami")',
101102
)
102103

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'],)
103109

104110
class HTTPResponse:
105111
def __init__(self, status, data=None):
@@ -412,6 +418,7 @@ def initialize_pickle_files():
412418
) # runpy
413419
initialize_pickle_file(f"{_root_path}/data/malicious15a.pkl", Malicious15(), 2)
414420
initialize_pickle_file(f"{_root_path}/data/malicious15b.pkl", Malicious15(), 4)
421+
initialize_pickle_file(f"{_root_path}/data/malicious16.pkl", Malicious16(), 0)
415422

416423
initialize_7z_file(
417424
f"{_root_path}/data/malicious1.7z",
@@ -752,10 +759,11 @@ def test_scan_directory_path():
752759
Global("bdb", "Bdb.run", SafetyLevel.Dangerous),
753760
Global("builtins", "exec", SafetyLevel.Dangerous),
754761
Global("builtins", "eval", SafetyLevel.Dangerous),
762+
Global("pip", "main", SafetyLevel.Dangerous),
755763
],
756-
scanned_files=32,
757-
issues_count=32,
758-
infected_files=27,
764+
scanned_files=33,
765+
issues_count=33,
766+
infected_files=28,
759767
scan_err=True,
760768
)
761769
compare_scan_results(scan_directory_path(f"{_root_path}/data/"), sr)

0 commit comments

Comments
 (0)