diff --git a/tools/reimport_feed.py b/tools/reimport_feed.py new file mode 100755 index 00000000..6095fb87 --- /dev/null +++ b/tools/reimport_feed.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +from vulnerabilitylookup import VulnerabilityLookup + +vl = VulnerabilityLookup() + + +def reimport_feed(): + for source in vl.get_sources(): + data = input(f'Do you want to reimport {source} from scratch?\n\tIf yes, type the name of the source. Otherwise, hit enter.') + if data == source: + if vl.del_source(source): + print(f'{source} deleted.') + else: + print(f'Unable to delete {source}') + else: + print(f'*not* deleting {source}') + + +if __name__ == "__main__": + print('Any feed you remove with this script will be reimported from scratch next time the feeder runs.') + reimport_feed() diff --git a/vulnerabilitylookup/__init__.py b/vulnerabilitylookup/__init__.py index e69de29b..0ac58b94 100644 --- a/vulnerabilitylookup/__init__.py +++ b/vulnerabilitylookup/__init__.py @@ -0,0 +1 @@ +from .vulnerabilitylookup import VulnerabilityLookup diff --git a/vulnerabilitylookup/vulnerabilitylookup.py b/vulnerabilitylookup/vulnerabilitylookup.py index 6c0983d5..d18c7fbf 100644 --- a/vulnerabilitylookup/vulnerabilitylookup.py +++ b/vulnerabilitylookup/vulnerabilitylookup.py @@ -63,6 +63,9 @@ def get_sources(self) -> Set[str]: last_updates = self.storage.hgetall('last_updates') return {name for name in last_updates.keys()} + def del_source(self, source: str) -> bool: + return self.storage.hdel('last_updates', source) + def get_info(self): last_updates = self.storage.hgetall('last_updates')