Skip to content

Commit 140ffaa

Browse files
committed
My GSoC'21 final report
The file already contains enough descriptive text Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
1 parent 6c433b8 commit 140ffaa

1 file changed

Lines changed: 177 additions & 0 deletions

File tree

docs/source/contribute/gsoc21.rst

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
Google Summer of Code 2021 Final Report
2+
============================================
3+
4+
Organization - `AboutCode <https://www.aboutcode.org>`_
5+
-----------------------------------------------------------
6+
| `Hritik Vijay <https://github.com/hritik14>`_
7+
| Project: `VulnerableCode <github.com/nexB/vulnerablecode>`_
8+
9+
Overview
10+
---------
11+
VulnerableCode is a decentralized python program to collect data about open
12+
source software vulnerabilities across the internet. My proposal for this
13+
year's Google Summer of Code involved improving the import speed, refactoring
14+
existing code, finding points for overall improvement and adding importers.
15+
16+
Detailed Report
17+
-----------------
18+
19+
Improve Import Time
20+
^^^^^^^^^^^^^^^^^^^^
21+
Profiling showed that a lot of time was being wasted during auto commits
22+
undertaken by django. Wraping the importer in an atomic block avoids lots of
23+
database commits and shows huge performance improvement. This simple change
24+
allows for much faster import times while not drastically changing the code
25+
structure::
26+
27+
Alpine: 202.7s -> 50.9s
28+
Archlinux 2116.6s -> 107.8s
29+
Gentoo 3176.3s -> 225.8s
30+
31+
Yielding an average of 93% reduction in time (14x faster)
32+
33+
More: https://github.com/nexB/vulnerablecode/pull/478
34+
35+
Speed up upstream tests
36+
^^^^^^^^^^^^^^^^^^^^^^^^
37+
VulnerableCode performs upstream tests for all the importers to make sure that
38+
any change change in upstream data structure is easily spotted. This allows us
39+
to have a look at failing importers without actually deploying the application.
40+
41+
Earlier, all of the importers were run one by one in order to verify that they
42+
are intact. While this being the obvious and the full proof way to detect any
43+
anomalies in the imported data schema, it did not work because the time
44+
required to run all the importers much exceeded 6 hours - which is the maximum
45+
time allowed for GitHub actions to run.
46+
With this PR, the updated_advisories method of each importer is expected to
47+
create at least one Advisory object. If it does so, the importer is marked
48+
working. While this is not full proof, it stays much below the allowed resource
49+
usage cap. In the end, this is a trade off between resource usage and data
50+
accuracy. This brings major performance improvement during the test.
51+
52+
| Before: ~6hrs, now ~9 minutes
53+
| More: https://github.com/nexB/vulnerablecode/pull/490
54+
55+
Improve Docker Configuration
56+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
57+
The preferred mode of deployment for VulnerableCode is deploying using Docker
58+
images. Docker configuration existing earlier was very insecure and
59+
rudimentary. I took the inspiration for a uniform Docker configuration from the
60+
ScanCodeIO project and provided with detailed documentation for installation
61+
using a docker image. The current configuration makes use of files like
62+
``docker.env`` to supply container's environment and ``.dockerignore`` to skip
63+
over any unnecessary files for deployment.
64+
65+
| More:
66+
| https://github.com/nexB/vulnerablecode/pull/497
67+
| https://github.com/nexB/vulnerablecode/pull/521
68+
69+
Add Makefile
70+
^^^^^^^^^^^^^
71+
Makefile usage is prevalent in sister projects like `ScanCodeIO
72+
<https://github.com/nexB/scancode.io>`_. It gives VulnerableCode a consistent
73+
behavior and provides a very friendly interface for invocations. This also
74+
avoids security risks like having a default django ``SECRET_KEY`` as it can be
75+
easily generated by a make target. I added a Makefile which has a similar
76+
usage as that of ScanCodeIO, replaced all the CI tests to use make, updated the
77+
relevant part of the documentation and updated settings to reject insecure
78+
deployments.
79+
80+
| More:
81+
| https://github.com/nexB/vulnerablecode/pull/497
82+
| https://github.com/nexB/vulnerablecode/pull/523
83+
84+
Use svn to collects tags in GitHubTagsAPI
85+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86+
Surprisingly, GitHub allows svn requests to repositories. Now we can
87+
have all the tags with a single request. This is much more efficient and
88+
gentle to the APIs.
89+
This was as issue since the importers based on GithubDataSource were `failing
90+
<https://github.com/nexB/vulnerablecode/issues/507>`_ because of being rate
91+
limited by GitHub.
92+
93+
| `Philippe <https://github.com/pombredanne>`_, thank you so much for the suggestion
94+
| More: https://github.com/nexB/vulnerablecode/pull/508
95+
96+
Separate import and improve operations - WIP
97+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
98+
This introduces a new concept of ``improver``. Earlier, data fetching and
99+
improvement were done as one single process by ``importer``. This meant that
100+
importers were convoluted and not very modular. The concept of ``improver``
101+
comes from the idea that an ``importer`` should only do one thing - import. Any
102+
further improvement on the data is delegated to the improvers. This allows for
103+
us to have multiple ways of improvement with certain confidence on the improved
104+
data making the import and improve operations modular and simpler to work with.
105+
As a bonus, writing importers will be very easy and welcome more contributors
106+
to the project. As of writing this report, this remains a work in progress
107+
which will be finished very soon.
108+
109+
More: https://github.com/nexB/vulnerablecode/pull/525
110+
111+
Others
112+
^^^^^^^
113+
- helper: split_markdown_front_matter: https://github.com/nexB/vulnerablecode/pull/443
114+
- Dump yaml in favor of saneyaml https://github.com/nexB/vulnerablecode/pull/452
115+
- Refactor package_managers https://github.com/nexB/vulnerablecode/pull/495/commits
116+
- Importers bugfix https://github.com/nexB/vulnerablecode/pull/505
117+
118+
Pre GSoC
119+
----------
120+
121+
I started to like VulnerableCode as soon as I laid eyes on the project. While
122+
exploring the codebase, I realized that there is a lot of room for improvement.
123+
Thus I looked for simple improvements and bugs to fix in the early stage, which
124+
were:
125+
126+
- `Correct API docs path and fix pytest invocation <https://github.com/nexB/vulnerablecode/pull/379>`_
127+
- `Explicity provide lxml parser to beautifulsoup <https://github.com/nexB/vulnerablecode/pull/382>`_
128+
- `Make sure vulnerability id is_cve or is_vulcoid <https://github.com/nexB/vulnerablecode/pull/389>`_
129+
- `Fix istio importer <https://github.com/nexB/vulnerablecode/pull/395>`_ (cleared a huge confusion about the codebase)
130+
- `Add me to AUTHORS <https://github.com/nexB/vulnerablecode/pull/405>`_ (Should've done this a lot earlier)
131+
- `Add unspecified scoring system <https://github.com/nexB/vulnerablecode/pull/415>`_
132+
- `Fix redhat import failure <https://github.com/nexB/vulnerablecode/pull/418>`_ (This one took a *lot* of effort to pinpoint)
133+
- `expose find_all_cve helper <https://github.com/nexB/vulnerablecode/pull/439>`_
134+
135+
Post GSoC - Future Plans and what's left
136+
-------------------------------------------
137+
I wish to carry on with the development of VulnerableCode and implement the
138+
ideas suggested by my mentors. This will require a lot of effort to bring
139+
VulnerableCode to a stable point. I hope to see VulnerableCode integrated into
140+
the ScanCode toolkit happen in a near future.
141+
142+
Further, if possible, I would like VulnerableCode to interact with other great
143+
open source tools like *Eclipse Steady* and *Prospector*. VulnerableCode,
144+
currently, works statically to collect all the vulnerabilities from different
145+
data sources, meanwhile there have been some developments with the Prospector
146+
project of Eclipse Steady. The project aims to scan fix-commits of the git
147+
repository in order to find out if the vulnerable part of a library was
148+
actually used in a project. It is not always the case that if a library is
149+
vulnerable then all the projects building upon it would be vulnerable too. It
150+
is crucial to identify if it is worth updating the library in use and dealing
151+
with the breaking changes. *Prospectus* is undergoing improvements in order to
152+
be released as a usable public tool. *Project KB* (Under Eclipse Steady) is
153+
also working on a "tool support for mining repositories and databases of
154+
advisories to establish the (missing) link between vulnerabilities (as
155+
described in natural language in the advisories) and the corresponding
156+
fix-commits". When these projects are ready for public use I would like to add
157+
them to VulnerableCode as a modules. I hope this will benefit both the projects
158+
and the downstream.
159+
160+
After everything mentioned above, writing importers and improvers is something
161+
that is still left. In my opinion, this needs to be addressed after having a
162+
stable structure for VulnerableCode.
163+
164+
Closing Thoughts
165+
-------------------
166+
I really enjoyed working on the project. There were ups and downs when I met
167+
some weird bugs but every one of them taught me something new about Python,
168+
Django and programming in general. The best part of working with my amazing
169+
mentors - Philippe and Shivam - were the `weekly meets
170+
<https://github.com/nexB/vulnerablecode/wiki/WeeklyMeetings#meeting-on-tuesday-2021-08-17-at-1400-utc>`_
171+
where we would together try to figure out how to proceed with the development.
172+
I learned something new with every call and interaction we had. Thank you so
173+
much my mentors for providing a very smooth experience and Google for showing
174+
me the guiding light for participation.
175+
176+
To the reader, I would really like you to read `this <https://en.wikipedia.org/wiki/Program_optimization#When_to_optimize>`_
177+
before Philippe asks you to ;)

0 commit comments

Comments
 (0)