Skip to content

Commit

Permalink
fix: error on illegal page size (#662)
Browse files Browse the repository at this point in the history
* fix: error on illegal page size

* `poetry black`

Co-authored-by: Thomas Harning Jr <[email protected]>

* move arg checking before saved query

* flake8

* chore(deps) poetry update and dev dependency update

* fix(tests) add tests for page size handling

* chore(black) fix trailing comma

---------

Co-authored-by: Andrew Alexander <[email protected]>
Co-authored-by: Thomas Harning Jr <[email protected]>
Co-authored-by: Andrew Alexander <[email protected]>
  • Loading branch information
4 people authored Jan 16, 2025
1 parent 8f95e6c commit 6e1f301
Show file tree
Hide file tree
Showing 5 changed files with 550 additions and 341 deletions.
14 changes: 14 additions & 0 deletions censys/cli/commands/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,13 @@ def cli_execute_saved_query_by_name(args: argparse.Namespace):
Args:
args (Namespace): Argparse Namespace.
"""
# do some sanity checking on page size before anything else
if args.page_size > 1000:
console.print(
"page size must be within [0,1000]. To fetch all pages, specify --pages -1 with any legal page size"
)

sys.exit(1)
s = InventorySearch(args.api_key)
q = SavedQueries(args.api_key)
# get query from name
Expand All @@ -573,6 +580,13 @@ def cli_execute_saved_query_by_id(args: argparse.Namespace):
Args:
args (Namespace): Argparse Namespace.
"""
# do some sanity checking on page size before anything else
if args.page_size > 1000:
console.print(
"page size must be within [0,1000]. To fetch all pages, specify --pages -1 with any legal page size"
)

sys.exit(1)
s = InventorySearch(args.api_key)
q = SavedQueries(args.api_key)
try:
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sphinx==7.2.6
sphinxcontrib-autoprogram==0.1.9
sphinx-rtd-theme==1.3.0
sphinx-rtd-theme==3.0.2
sphinx-prompt==1.8.0
sphinx-tabs==3.4.1
sphinx-copybutton==0.5.2
Loading

0 comments on commit 6e1f301

Please sign in to comment.