-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c21f851
commit d3e5d75
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# SPDX-FileCopyrightText: 2023 Greenbone AG | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
import asyncio | ||
from argparse import Namespace | ||
|
||
from pontos.nvd.source.api import SourceApi | ||
|
||
from ._parser import parse_args | ||
|
||
__all__ = ("SourceApi",) | ||
|
||
|
||
async def query_changes(args: Namespace) -> None: | ||
async with SourceApi() as api: | ||
async for source in api.sources( | ||
source_identifier=args.source_identifier, | ||
request_results=args.number, | ||
start_index=args.start, | ||
): | ||
print(source) | ||
|
||
|
||
def main() -> None: | ||
try: | ||
args = parse_args() | ||
asyncio.run(query_changes(args)) | ||
except KeyboardInterrupt: | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# SPDX-FileCopyrightText: 2024 Greenbone AG | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
from argparse import ArgumentParser, Namespace | ||
from typing import Optional, Sequence | ||
|
||
import shtab | ||
|
||
|
||
def parse_args(args: Optional[Sequence[str]] = None) -> Namespace: | ||
parser = ArgumentParser() | ||
shtab.add_argument_to(parser) | ||
parser.add_argument( | ||
"--source-identifier", | ||
help="Get sources record for this source identifier", | ||
) | ||
parser.add_argument( | ||
"--number", "-n", metavar="N", help="Request only N sources", type=int | ||
) | ||
parser.add_argument( | ||
"--start", | ||
"-s", | ||
help="Index of the first source to request.", | ||
type=int, | ||
default=0, | ||
) | ||
return parser.parse_args(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters