|
1 | | -# Copyright (c) 2017 nexB Inc. and others. All rights reserved. |
2 | | -# http://nexb.com and https://github.com/nexB/vulnerablecode/ |
3 | | -# The VulnerableCode software is licensed under the Apache License version 2.0. |
4 | | -# Data generated with VulnerableCode require an acknowledgment. |
5 | | -# |
6 | | -# You may not use this software except in compliance with the License. |
7 | | -# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 |
8 | | -# Unless required by applicable law or agreed to in writing, software distributed |
9 | | -# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
10 | | -# CONDITIONS OF ANY KIND, either express or implied. See the License for the |
11 | | -# specific language governing permissions and limitations under the License. |
12 | | -# |
13 | | -# When you publish or redistribute any data created with VulnerableCode or any VulnerableCode |
14 | | -# derivative work, you must accompany this data with the following acknowledgment: |
15 | | -# |
16 | | -# Generated with VulnerableCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES |
17 | | -# OR CONDITIONS OF ANY KIND, either express or implied. No content created from |
18 | | -# VulnerableCode should be considered or used as legal advice. Consult an Attorney |
19 | | -# for any legal advice. |
20 | | -# VulnerableCode is a free software code scanning tool from nexB Inc. and others. |
21 | | -# Visit https://github.com/nexB/vulnerablecode/ for support and download. |
22 | | -import dataclasses |
| 1 | +# # Copyright (c) 2017 nexB Inc. and others. All rights reserved. |
| 2 | +# # http://nexb.com and https://github.com/nexB/vulnerablecode/ |
| 3 | +# # The VulnerableCode software is licensed under the Apache License version 2.0. |
| 4 | +# # Data generated with VulnerableCode require an acknowledgment. |
| 5 | +# # |
| 6 | +# # You may not use this software except in compliance with the License. |
| 7 | +# # You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 |
| 8 | +# # Unless required by applicable law or agreed to in writing, software distributed |
| 9 | +# # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 10 | +# # CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 11 | +# # specific language governing permissions and limitations under the License. |
| 12 | +# # |
| 13 | +# # When you publish or redistribute any data created with VulnerableCode or any VulnerableCode |
| 14 | +# # derivative work, you must accompany this data with the following acknowledgment: |
| 15 | +# # |
| 16 | +# # Generated with VulnerableCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES |
| 17 | +# # OR CONDITIONS OF ANY KIND, either express or implied. No content created from |
| 18 | +# # VulnerableCode should be considered or used as legal advice. Consult an Attorney |
| 19 | +# # for any legal advice. |
| 20 | +# # VulnerableCode is a free software code scanning tool from nexB Inc. and others. |
| 21 | +# # Visit https://github.com/nexB/vulnerablecode/ for support and download. |
| 22 | +# import dataclasses |
23 | 23 |
|
24 | | -import requests |
25 | | -import saneyaml |
26 | | -from bs4 import BeautifulSoup |
27 | | -from packageurl import PackageURL |
| 24 | +# import requests |
| 25 | +# import saneyaml |
| 26 | +# from bs4 import BeautifulSoup |
| 27 | +# from packageurl import PackageURL |
28 | 28 |
|
29 | | -from vulnerabilities.data_source import Advisory |
30 | | -from vulnerabilities.data_source import DataSource |
31 | | -from vulnerabilities.data_source import DataSourceConfiguration |
32 | | -from vulnerabilities.helpers import create_etag |
| 29 | +# from vulnerabilities.data_source import Advisory |
| 30 | +# from vulnerabilities.data_source import DataSource |
| 31 | +# from vulnerabilities.data_source import DataSourceConfiguration |
| 32 | +# from vulnerabilities.helpers import create_etag |
33 | 33 |
|
34 | 34 |
|
35 | | -@dataclasses.dataclass |
36 | | -class SUSEBackportsConfiguration(DataSourceConfiguration): |
37 | | - url: str |
38 | | - etags: dict |
| 35 | +# @dataclasses.dataclass |
| 36 | +# class SUSEBackportsConfiguration(DataSourceConfiguration): |
| 37 | +# url: str |
| 38 | +# etags: dict |
39 | 39 |
|
40 | 40 |
|
41 | | -class SUSEBackportsDataSource(DataSource): |
| 41 | +# class SUSEBackportsDataSource(DataSource): |
42 | 42 |
|
43 | | - CONFIG_CLASS = SUSEBackportsConfiguration |
| 43 | +# CONFIG_CLASS = SUSEBackportsConfiguration |
44 | 44 |
|
45 | | - @staticmethod |
46 | | - def get_all_urls_of_backports(url): |
47 | | - r = requests.get(url) |
48 | | - soup = BeautifulSoup(r.content, "lxml") |
49 | | - for a_tag in soup.find_all("a", href=True): |
50 | | - if a_tag["href"].endswith(".yaml") and a_tag["href"].startswith("backports"): |
51 | | - yield url + a_tag["href"] |
| 45 | +# @staticmethod |
| 46 | +# def get_all_urls_of_backports(url): |
| 47 | +# r = requests.get(url) |
| 48 | +# soup = BeautifulSoup(r.content, "lxml") |
| 49 | +# for a_tag in soup.find_all("a", href=True): |
| 50 | +# if a_tag["href"].endswith(".yaml") and a_tag["href"].startswith("backports"): |
| 51 | +# yield url + a_tag["href"] |
52 | 52 |
|
53 | | - def updated_advisories(self): |
54 | | - advisories = [] |
55 | | - all_urls = self.get_all_urls_of_backports(self.config.url) |
56 | | - for url in all_urls: |
57 | | - if not create_etag(data_src=self, url=url, etag_key="ETag"): |
58 | | - continue |
59 | | - advisories.extend(self.process_file(self._fetch_yaml(url))) |
60 | | - return self.batch_advisories(advisories) |
| 53 | +# def updated_advisories(self): |
| 54 | +# advisories = [] |
| 55 | +# all_urls = self.get_all_urls_of_backports(self.config.url) |
| 56 | +# for url in all_urls: |
| 57 | +# if not create_etag(data_src=self, url=url, etag_key="ETag"): |
| 58 | +# continue |
| 59 | +# advisories.extend(self.process_file(self._fetch_yaml(url))) |
| 60 | +# return self.batch_advisories(advisories) |
61 | 61 |
|
62 | | - def _fetch_yaml(self, url): |
| 62 | +# def _fetch_yaml(self, url): |
63 | 63 |
|
64 | | - try: |
65 | | - resp = requests.get(url) |
66 | | - resp.raise_for_status() |
67 | | - return saneyaml.load(resp.content) |
| 64 | +# try: |
| 65 | +# resp = requests.get(url) |
| 66 | +# resp.raise_for_status() |
| 67 | +# return saneyaml.load(resp.content) |
68 | 68 |
|
69 | | - except requests.HTTPError: |
70 | | - return {} |
| 69 | +# except requests.HTTPError: |
| 70 | +# return {} |
71 | 71 |
|
72 | | - @staticmethod |
73 | | - def process_file(yaml_file): |
74 | | - advisories = [] |
75 | | - try: |
76 | | - for pkg in yaml_file[0]["packages"]: |
77 | | - for version in yaml_file[0]["packages"][pkg]["fixed"]: |
78 | | - for vuln in yaml_file[0]["packages"][pkg]["fixed"][version]: |
79 | | - # yaml_file specific data can be added |
80 | | - purl = [ |
81 | | - PackageURL(name=pkg, type="rpm", version=version, namespace="opensuse") |
82 | | - ] |
83 | | - advisories.append( |
84 | | - Advisory( |
85 | | - vulnerability_id=vuln, |
86 | | - resolved_package_urls=purl, |
87 | | - summary="", |
88 | | - impacted_package_urls=[], |
89 | | - ) |
90 | | - ) |
91 | | - except TypeError: |
92 | | - # could've used pass |
93 | | - return advisories |
| 72 | +# @staticmethod |
| 73 | +# def process_file(yaml_file): |
| 74 | +# advisories = [] |
| 75 | +# try: |
| 76 | +# for pkg in yaml_file[0]["packages"]: |
| 77 | +# for version in yaml_file[0]["packages"][pkg]["fixed"]: |
| 78 | +# for vuln in yaml_file[0]["packages"][pkg]["fixed"][version]: |
| 79 | +# # yaml_file specific data can be added |
| 80 | +# purl = [ |
| 81 | +# PackageURL(name=pkg, type="rpm", version=version, namespace="opensuse") |
| 82 | +# ] |
| 83 | +# advisories.append( |
| 84 | +# Advisory( |
| 85 | +# vulnerability_id=vuln, |
| 86 | +# resolved_package_urls=purl, |
| 87 | +# summary="", |
| 88 | +# impacted_package_urls=[], |
| 89 | +# ) |
| 90 | +# ) |
| 91 | +# except TypeError: |
| 92 | +# # could've used pass |
| 93 | +# return advisories |
94 | 94 |
|
95 | | - return advisories |
| 95 | +# return advisories |
0 commit comments