Skip to content

#6 Debian & #7 Ubuntu Scrapers - #14

Merged
tdruez merged 26 commits into
developfrom
scraper
Jul 14, 2017
Merged

#6 Debian & #7 Ubuntu Scrapers#14
tdruez merged 26 commits into
developfrom
scraper

Conversation

@kartiksibal

@kartiksibal kartiksibal commented Jul 7, 2017

Copy link
Copy Markdown
Contributor

What it does:

  1. Gets the job done.

Things remaining:

  1. Add test cases.
  2. Remove boilerplate.

Signed-off-by: Kartik Sibal <kartiksibal@gmail.com>
Signed-off-by: Kartik Sibal <kartiksibal@gmail.com>
@kartiksibal kartiksibal changed the title #6 Debian & Ubuntu Scrapers #6 Debian & #7 Ubuntu Scrapers Jul 7, 2017
kartiksibal and others added 9 commits July 7, 2017 09:39
Comment thread test_scrapers.py Outdated
# Fix Me: The test data doesn't accurately depict the
# actual debian website on which, the code under testing
# is written
from scraper import debian

@kartiksibal kartiksibal Jul 11, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tdruez @pombredanne The main debian website (https://security-tracker.debian.org/tracker/), has several child datasets eg: https://security-tracker.debian.org/tracker/status/release/unstable.

The scraping code, firsts visits the main website, extracts the child links, and then visits the child links to extract data. I couldn't form a test data, that could depict this behaviour.

What do you suggest?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

firsts visits the main website, extracts the child links, and then visits the child links to extract data.

Then I suggest those 3 logics should be in 3 separate functions, this would make thing much easier to test as well.

Comment thread scraper/debian.py Outdated


def debian_data():
cve_id = []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those variables are out of their scope.

Comment thread scraper/debian.py Outdated

for child_links in range(6):
# Extract package info from all the child datasets
child_url = urlopen("https://security-tracker.debian.org"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part should be refactored into its own function.

Comment thread test_scrapers.py Outdated
# Fix Me: The test data doesn't accurately depict the
# actual debian website on which, the code under testing
# is written
from scraper import debian

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the import in the function instead of on top of the module?

Comment thread test_scrapers.py Outdated
# Visit https://github.com/nexB/vulnerablecode/ for support and download.

import bs4 as bs
from mock import Mock

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove un-used imports.

tdruez and others added 8 commits July 11, 2017 10:55
Signed-off-by: Thomas Druez <tdruez@nexb.com>
Signed-off-by: Kartik Sibal <kartiksibal@gmail.com>
Signed-off-by: Kartik Sibal <kartiksibal@gmail.com>
Signed-off-by: Kartik Sibal <kartiksibal@gmail.com>
Signed-off-by: Kartik Sibal <kartiksibal@gmail.com>
tdruez added 5 commits July 13, 2017 11:57
- Add tests runner in the travis config
- Cleanup

Signed-off-by: Thomas Druez <tdruez@nexb.com>
Signed-off-by: Thomas Druez <tdruez@nexb.com>
Signed-off-by: Thomas Druez <tdruez@nexb.com>
Comment thread scraper/debian.py

# if package name is empty, use the previous package name
if href == '/tracker/source-package/':
package_name.append(pkg)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning: The pkg may be referenced before assignment.
IE: if the previous if condition did not check, pkg will not be available.

@tdruez

tdruez commented Jul 14, 2017

Copy link
Copy Markdown
Contributor

@kartiksibal the current data structure for the returned CVEs is not easily usable, instead of the current 3 lists of strings, we should return a single list of CVEs dictionaries.

Instead of:

(
    ['CVE-2016-5416', 'CVE-2012-6655'],  
    ['389-ds-base', 'accountsservice'],  
    ['not yet assigned', 'not yet assigned'],
)

Return:

[
    {
        'cve_id': 'CVE-2016-5416', 
        'package_name': '389-ds-base', 
        'vulnerability_status': 'not yet assigned',
    },
    {
        'cve_id': 'CVE-2012-6655', 
        'package_name': 'accountsservice', 
        'vulnerability_status': 'not yet assigned',
    },
]

It will be much easier to use that data structure to then create model instances (save the data in the DB).

@tdruez
tdruez merged commit f0e46ce into develop Jul 14, 2017
@tdruez
tdruez deleted the scraper branch July 14, 2017 00:34
pombredanne pushed a commit that referenced this pull request Apr 2, 2025
Merge changes from develop to main
pombredanne added a commit that referenced this pull request Apr 2, 2025
Add support for gems and improve RPM support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants