intel / cve-bin-tool

The CVE Binary Tool helps you determine if your system includes known vulnerabilities. You can scan binaries for over 200 common, vulnerable components (openssl, libpng, libxml2, expat and others), or if you know the components used, you can get a list of known vulnerabilities associated with an SBOM or a list of components and versions.
https://cve-bin-tool.readthedocs.io/en/latest/
GNU General Public License v3.0
1.21k stars 460 forks source link

docs: Add docstrings to cve_bin_tool/strings.py #3711

Closed terriko closed 9 months ago

terriko commented 9 months ago

We haven't been entirely consistent about adding python docstrings to every function, and I'd like to start improving the codebase. I'm filing separate tickets for each file I want updated so GSoC folk can claim them more easily -- please do not claim more than one of these issues; they are intended for beginners to get their first commit.

What is a docstring?

Here's a tutorial on docstrings in case you're not sure what they are. Basically I want someone to write a short sentence explaining what a function does and have it put at the top of the function in the way that python expects docstrings to look. (You can also do classes and methods.) Among other things, docstrings can be used by integrated development environments (IDEs) to give contributors a quick overview of the function without having to read the code.

This issue

This issue is for updating the file listed in the title of the issue: cve_bin_tool/strings.py

We are using interrogate (a tool for checking docstrings) as follows: interrogate -vv -i -I -M -C -n -p cve_bin_tool/strings.py

(venv-3.10) [terri@cedar cve-bin-tool]$ interrogate -vv -i -I -M -C -n -p cve_bin_tool/strings.py
========================= Coverage for /home/terri/Code/cve-bin-tool/cve_bin_tool/ ==========================
--------------------------------------------- Detailed Coverage ---------------------------------------------
| Name                                                          |                                    Status |
|---------------------------------------------------------------|-------------------------------------------|
| strings.py                                                    |                                           |
|   Strings (L17)                                               |                                    MISSED |
|     Strings.aio_parse (L27)                                   |                                    MISSED |
|     Strings.parse (L41)                                       |                                    MISSED |
|   parse_strings (L45)                                         |                                   COVERED |
|---------------------------------------------------------------|-------------------------------------------|

-------------------------------------------------- Summary --------------------------------------------------
| Name                      |             Total |             Miss |             Cover |             Cover% |
|---------------------------|-------------------|------------------|-------------------|--------------------|
| strings.py                |                 4 |                3 |                 1 |                25% |
|---------------------------|-------------------|------------------|-------------------|--------------------|
| TOTAL                     |                 4 |                3 |                 1 |              25.0% |
------------------------------ RESULT: FAILED (minimum: 80.0%, actual: 25.0%) -------------------------------

You can run that locally to see if you're done, but we also recommend using pre-commit to run pre-checks for you before submitting a pull request. Instructions here:

https://cve-bin-tool.readthedocs.io/en/latest/CONTRIBUTING.html#using-pre-commit-to-run-linters-automatically

Or in short, go to the main cve-bin-tool directory and run the following:

pip install pre-commit
pre-commit install --hook-type pre-commit --hook-type commit-msg

Short tips for new contributors:

Claiming issues:

inosmeet commented 9 months ago

I'll be working on this.