Skip to content

Commit f54ec8a

Browse files
pythonJaRvispythonJaRvis
authored andcommitted
commit
1 parent 91e372b commit f54ec8a

File tree

3,033 files changed

+110942
-100823
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,033 files changed

+110942
-100823
lines changed

.DS_Store

-2 KB
Binary file not shown.

Jarvis.zip

50.9 MB
Binary file not shown.

Jarvis/.DS_Store

-8 KB
Binary file not shown.

Jarvis/ReadMe.md

Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
2+
3+
4+
5+
# Jarvis artifact
6+
7+
This is the readme file of Jarvis artifact.
8+
9+
10+
11+
12+
## Dataset and Ground truth
13+
14+
The micro-benchmark and macro-benchmark is provide in `dataset` and `ground_truth` directory.
15+
16+
## Getting Jarvis to run
17+
18+
Prerequisites:
19+
* Python = 3.8
20+
* PyCG: tool/PyCG
21+
* Jarvis: tool/Jarvis
22+
23+
run `jarvis_cli.py`.
24+
25+
Jarvis usage:
26+
27+
```bash
28+
$ python3 tool/Jarvis/jarvis_cli.py [module_path1 module_path2 module_path3...] [--package] [--decy] [-o output_path]
29+
```
30+
31+
Jarvis help:
32+
33+
```bash
34+
$ python3 tool/Jarvis/jarvis_cli.py -h
35+
usage: jarvis_cli.py [-h] [--package PACKAGE] [--decy] [--precision]
36+
[--moduleEntry [MODULEENTRY ...]]
37+
[--operation {call-graph,key-error}] [-o OUTPUT]
38+
[module ...]
39+
40+
positional arguments:
41+
module modules to be processed, which are also 'Demands' in D.W. mode
42+
43+
options:
44+
-h, --help show this help message and exit
45+
--package PACKAGE Package containing the code to be analyzed
46+
--decy whether analyze the dependencies
47+
--precision whether flow-sensitive
48+
--entry-point [MODULEENTRY ...]
49+
Entry functions to be processed
50+
-o OUTPUT, --output OUTPUT
51+
Output call graph path
52+
```
53+
54+
*Example 1:* analyze bpytop.py in E.A. mode.
55+
56+
```bash
57+
$ python3 tool/Jarvis/jarvis_cli.py dataset/macro-benchmark/pj/bpytop/bpytop.py --package dataset/macro-benchmark/pj/bpytop -o jarvis.json
58+
```
59+
60+
*Example 2:* analyze bpytop.py in D.W. mode. Note we should prepare all the dependencies in the virtual environment.
61+
62+
```bash
63+
# create virtualenv environment
64+
$ virtualenv venv python=python3.8
65+
# install Dependencies in virtualenv environment
66+
$ python3 -m pip install psutil
67+
# run jarvis
68+
$ python3 tool/Jarvis/jarvis_cli.py dataset/macro-benchmark/pj/bpytop/bpytop.py --package dataset/macro-benchmark/pj/bpytop --decy -o jarvis.jso
69+
```
70+
71+
72+
73+
74+
## Evaluation
75+
76+
### RQ1 and RQ2 Setup
77+
78+
cd to the root directory of the unzipped files.
79+
80+
```bash
81+
# 1. run micro_benchmark
82+
$ ./reproducing_RQ12_setup/micro_benchmark/test_All.sh
83+
# 2. run macro_benchmark
84+
$ ./reproducing_RQ12_setup/macro_benchmark/pycg_EA.sh
85+
# PyCG iterates once
86+
$ ./reproducing_RQ12_setup/macro_benchmark/pycg_EW.sh 1
87+
# PyCG iterates twice
88+
$ ./reproducing_RQ12_setup/macro_benchmark/pycg_EW.sh 2
89+
# PyCG iterates to convergence
90+
$ ./reproducing_RQ12_setup/macro_benchmark/pycg_EW.sh
91+
$ ./reproducing_RQ12_setup/macro_benchmark/jarvis_DA.sh
92+
$ ./reproducing_RQ12_setup/macro_benchmark/jarvis_EA.sh
93+
$ ./reproducing_RQ12_setup/macro_benchmark/jarvis_DW.sh
94+
```
95+
96+
### RQ1. Scalability Evaluation
97+
98+
99+
#### Scalability results
100+
Run
101+
102+
```bash
103+
$ python3 ./reproducing_RQ1/gen_table.py
104+
```
105+
106+
The results are shown below:
107+
108+
![scalability](reproducing_RQ1/scalability.png)
109+
110+
#### AGs and FAGs
111+
112+
Run
113+
114+
```
115+
$ python3 ./reproducing_RQ1/FAG/plot.py
116+
```
117+
118+
The generated graphs are `pycg-ag.pdf`, `pycg-change-ag.pdf` and `jarvis-fag.pdf`, where they represents Fig. 9a, Fig. 9b and Fig 10, correspondingly.
119+
120+
121+
122+
### RQ2. Accuracy Evaluation
123+
124+
#### Accuracy results
125+
126+
Run
127+
128+
```bash
129+
$ python3 ./reproducing_RQ2/gen_table.py
130+
```
131+
132+
The generated results:
133+
134+
![accuracy](reproducing_RQ2/accuracy.png)
135+
136+
137+
138+
### Case Study: Fine-grained Tracking of Vulnerable Dependencies
139+
140+
#### 1. Target projects
141+
142+
[Fastapi](https://github.com/tiangolo/fastapi), [Httpie](https://github.com/httpie/httpie), [Scrapy](https://github.com/scrapy/scrapy), [Lightning](github.com/Lightning-AI/lightning), [Airflow](https://github.com/apache/airflow),[sherlock](https://github.com/sherlock-project/sherlock),[wagtail](https://github.com/wagtail/wagtail)
143+
144+
#### 2. Vulnerable libraries in Top 10 dependencies
145+
146+
* ~~**Html**: CVE-2018-17142~~ (Golang)
147+
* **cryptography**: [CVE-2016-9243](https://github.com/pyca/cryptography/commit/b924696b2e8731f39696584d12cceeb3aeb2d874), [CVE-2020-36242](https://github.com/pyca/cryptography/compare/3.3.1...3.3.2), [CVE-2018-10903](https://github.com/pyca/cryptography/pull/4342/commits/688e0f673bfbf43fa898994326c6877f00ab19ef)
148+
* **urllib3**: [CVE-2021-33503](https://github.com/urllib3/urllib3/commit/2d4a3fee6de2fa45eb82169361918f759269b4ec), [CVE-2019-11324](https://github.com/urllib3/urllib3/compare/a6ec68a...1efadf4), [CVE-2019-11236](https://github.com/urllib3/urllib3/issues/1553), [CVE-2020-7212](https://github.com/urllib3/urllib3/commit/a74c9cfbaed9f811e7563cfc3dce894928e0221a)
149+
* **requests**: [CVE-2014-1830](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=733108), [CVE-2015-2296](https://github.com/kennethreitz/requests/commit/3bd8afbff29e50b38f889b2f688785a669b9aafc), [CVE-2018-18074](https://github.com/psf/requests/commit/c45d7c49ea75133e52ab22a8e9e13173938e36ff)
150+
* ~~**psutil**: CVE-2019-18874~~ (C)
151+
* ~~**Numpy**: CVE-2021-33430, CVE-2014-1858, CVE-2014-1859, CVE-2017-12852~~ (cpp)
152+
* ~~**lxml**: CVE-2021-28957, CVE-2018-19787, CVE-2020-27783, CVE-2014-3146~~ (js)
153+
* **jinja2** : [CVE-2020-28493](https://github.com/pallets/jinja/pull/1343/commits/ef658dc3b6389b091d608e710a810ce8b87995b3), [CVE-2014-0012](https://github.com/mitsuhiko/jinja2/commit/acb672b6a179567632e032f547582f30fa2f4aa7), [CVE-2014-1402](http://advisories.mageia.org/MGASA-2014-0028.html)
154+
* **sqlalchemy** : [CVE-2019-7164](https://github.com/sqlalchemy/sqlalchemy/issues/4481), [CVE-2019-7548](https://github.com/sqlalchemy/sqlalchemy/issues/4481#issuecomment-461204518)
155+
* **httpx**: [CVE-2021-41945](https://github.com/encode/httpx/pull/2214)
156+
157+
The CVEs of html , numpy , lxml,psutil don't relate to Python , we don't care them.
158+
159+
#### 3. Vulnerable projects using dependency analysis
160+
161+
##### sherlock
162+
163+
```
164+
- sherlock.sherlock
165+
- requests(v2.28.0)
166+
- urllib3(v1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
167+
- sherlock.sites
168+
- requests(v.2.28.0)
169+
- urllib3(v1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
170+
```
171+
172+
##### airflow
173+
174+
```
175+
- airflow.kubernetes.kube_client
176+
- urllib3(v1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
177+
- airflow.providers.cncf.kubernetes.operators.pod
178+
- urllib3(v1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
179+
- airflow.providers.cncf.kubernetes.utils.pod_manager
180+
- urllib3(v1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
181+
- airflow.executors.kubernetes_executor
182+
- urllib3(v1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
183+
......
184+
```
185+
186+
##### wagtail
187+
188+
```
189+
- wagtail.contrib.frontend_cache.backends
190+
- requests(v2.28.0)
191+
- urllib3(v1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
192+
```
193+
194+
##### Httpie
195+
196+
```
197+
- httpie.client
198+
- urllib3(v1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
199+
- httpie.ssl_
200+
- urllib3(v1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
201+
- httpie.models
202+
- urllib3(1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
203+
```
204+
205+
##### Scrapy
206+
207+
```
208+
- scrapy.downloadermiddlewares.cookies
209+
- tldextract(v3.4.4)
210+
- requests(v2.28.0)
211+
- urllib3(v1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
212+
```
213+
214+
##### Lightning
215+
216+
```
217+
- lightning.app.utilities.network
218+
- requests(v2.28.0)
219+
- urllib3(v1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
220+
- lightning.app.utilities.network
221+
- requests(v2.28.0)
222+
- urllib3(v1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
223+
- lightning.app.utilities.network
224+
- requests(v2.28.0)
225+
- urllib3(v1.26.0) ---- [CVE-2021-33503,CVE-2019-11324,CVE-2019-11236,CVE-2020-7212]
226+
...
227+
```
228+
229+
#### 4. Vulnerable projects using method-level invocation analysis
230+
231+
##### Fastapi
232+
233+
According to the [patch commit](https://github.com/urllib3/urllib3/commit/2d4a3fee6de2fa45eb82169361918f759269b4ec), the vulnerable method of CVE-2021-33503 in urllib3 is `urllib3.util.url`.
234+
235+
Below is the method-level invocation path:
236+
237+
##### Httpie
238+
239+
```
240+
- httpie.apapters.<main>
241+
- requests.adapters.<main>
242+
- urllib3.contrib.socks.<main>
243+
- Urllib3.util.url.<main> ---- CVE-2021-33503
244+
```
245+
246+
##### Scrapy
247+
```
248+
- scrapy.downloadermiddlewares.cookies.<main>
249+
- tldextract.__init__.<main>
250+
- tldextract.tldextract.<main>
251+
- tldextract.suffix_list.<main>
252+
- requests_file.<main>
253+
- requests.adapters.<main>
254+
- Urllib3.util.url.<main> ---- CVE-2021-33503
255+
```
256+
##### Lighting
257+
```
258+
- lightning.app.utilities.network.<main>
259+
- requests.adapters.<main>
260+
- urllib3.contrib.socks.<main>
261+
- Urllib3.util.url.<main> ---- CVE-2021-33503
262+
```
263+
##### Airflow
264+
```
265+
- airflow.providers.amazon.aws.hooks.base_aws.BaseSessionFactory._get_idp_response
266+
- requests.adapters.<main>
267+
- urllib3.contrib.sock.<main>
268+
- urllib3.util.url.<main> ---- CVE-2021-33503
269+
```
270+
271+
**PS:** <main> represents body code block of python file.(Because python doesn't need entry function)
272+
273+
### Acknowledgements
274+
275+
276+
Our artifact has reused part of the functionalities from third party libraries. i.e., [PyCG](https://github.com/vitsalis/PyCG).
277+
278+
Vitalis Salis et al. PyCG: Practical Call Graph Generation in Python. In 43rd International Conference on Software Engineering (ICSE), 25–28 May 2021.
279+

Jarvis/dataset/.DS_Store

10 KB
Binary file not shown.

0 commit comments

Comments
 (0)