1- # Copyright (c) nexB Inc. and others. All rights reserved.
1+ # Copyright (c) nexB Inc. and others. All rights reserved.
22# http://nexb.com and https://github.com/nexB/vulnerablecode/
3- # The VulnerableCode software is licensed under the Apache License version
3+ # The VulnerableCode software is licensed under the Apache License version 2.0.
44# Data generated with VulnerableCode require an acknowledgment.
55#
66# 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/LICE
8- # Unless required by applicable law or agreed to in writing, software dist
9- # under the License is distributed on an ' AS IS' BASIS, WITHOUT WARRANTIES
10- # CONDITIONS OF ANY KIND, either express or implied. See the License for t
11- # specific language governing permissions and limitations under the Licens
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.
1212#
13- # When you publish or redistribute any data created with VulnerableCode or
14- # derivative work, you must accompany this data with the following acknowl
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:
1515#
16- # Generated with VulnerableCode and provided on an ' AS IS' BASIS, WITHOUT
17- # OR CONDITIONS OF ANY KIND, either express or implied. No content create
18- # VulnerableCode should be considered or used as legal advice. Consult an
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
1919# for any legal advice.
20- # VulnerableCode is a free software from nexB Inc. and others.
20+ # VulnerableCode is a free software tool from nexB Inc. and others.
2121# Visit https://github.com/nexB/vulnerablecode/ for support and download.
2222
2323import asyncio
3434from vulnerabilities .data_source import DataSourceConfiguration
3535from vulnerabilities .data_source import Reference
3636from vulnerabilities .package_managers import GitHubTagsAPI
37+ from vulnerabilities .helpers import create_etag
3738
3839
3940@dataclasses .dataclass
4041class NginxDataSourceConfiguration (DataSourceConfiguration ):
41- etag : dict
42+ etags : dict
4243
4344
4445class NginxDataSource (DataSource ):
@@ -57,24 +58,12 @@ def set_api(self):
5758
5859 def updated_advisories (self ):
5960 advisories = []
60- if self . create_etag ():
61+ if create_etag (data_src = self , url = self . url , etag_key = "ETag" ):
6162 self .set_api ()
6263 data = requests .get (self .url ).content
6364 advisories .extend (self .to_advisories (data ))
6465 return self .batch_advisories (advisories )
6566
66- def create_etag (self ):
67- etag = requests .head (self .url ).headers .get ("ETag" )
68- if not etag :
69- return True
70-
71- elif self .url in self .config .etag :
72- if self .config .etag [self .url ] == etag :
73- return False
74-
75- self .config .etag [self .url ] = etag
76- return True
77-
7867 def to_advisories (self , data ):
7968 advisories = []
8069 soup = BeautifulSoup (data )
0 commit comments