Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set allow_nan=False where relevant, including bumping panther-core #540

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jsonpath-ng = "==1.5.3"
jsonschema = "4.19.0"
nested-lookup = "==0.2.25"
packaging = "==23.1"
panther-core = "==0.11.1"
panther-core = "==0.11.2"
ply = "==3.11"
policyuniverse = "==1.5.1.20230817"
python-dateutil = "==2.8.2"
Expand Down
538 changes: 265 additions & 273 deletions Pipfile.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions panther_analysis_tool/analysis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def get_simple_detections_as_python(
"""Returns simple detections with transpiled Python."""
enriched_specs = []
if backend is not None:
batch = [json.dumps(spec.analysis_spec) for spec in specs]
batch = [json.dumps(spec.analysis_spec, allow_nan=False) for spec in specs]
try:
params = TranspileToPythonParams(data=batch)
response = backend.transpile_simple_detection_to_python(params)
Expand Down Expand Up @@ -547,7 +547,8 @@ def transpile_inline_filters(

if backend is not None:
batch = [
json.dumps(d.analysis_spec.get("InlineFilters")) for d in all_detections_with_filters
json.dumps(d.analysis_spec.get("InlineFilters"), allow_nan=False)
for d in all_detections_with_filters
]
try:
params = TranspileFiltersParams(data=batch, pat_version=VERSION_STRING)
Expand Down
2 changes: 1 addition & 1 deletion panther_analysis_tool/backend/lambda_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def get_rule_body(self, params: GetRuleBodyParams) -> BackendResponse[GetRuleBod
@staticmethod
def _serialize_request(data: Dict[str, Any]) -> str:
logging.debug(">>> %s", data)
return json.dumps(data)
return json.dumps(data, allow_nan=False)

@staticmethod
def _parse_response(response: Dict[str, Any]) -> BackendResponse[Dict[str, Any]]:
Expand Down
4 changes: 3 additions & 1 deletion panther_analysis_tool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,9 @@ def publish_github(tag: str, body: str, headers: dict, release_url: str, release
payload = {"tag_name": tag, "draft": True}
if body:
payload["body"] = body
response = requests.post(release_url, data=json.dumps(payload), headers=headers, timeout=10)
response = requests.post(
release_url, data=json.dumps(payload, allow_nan=False), headers=headers, timeout=10
)
if response.status_code != 201:
logging.error("error creating release (%s) in repo (%s)", tag, release_url)
logging.error(response.json())
Expand Down
65 changes: 34 additions & 31 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,59 @@ appdirs==1.4.4
async-timeout==4.0.3; python_version >= '3.7'
attrs==24.2.0; python_version >= '3.7'
backoff==2.2.1; python_version >= '3.7' and python_version < '4.0'
boto3==1.28.44; python_version >= '3.7'
botocore==1.31.44; python_version >= '3.7'
certifi==2023.7.22; python_version >= '3.6'
chardet==5.2.0; python_version >= '3.7'
boto3==1.28.44
botocore==1.31.44
certifi==2023.7.22
chardet==5.2.0
charset-normalizer==3.3.2; python_full_version >= '3.7.0'
click==8.1.7; python_version >= '3.7'
colorama==0.4.6; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6'
contextlib2==21.6.0; python_version >= '3.6'
decorator==5.1.1; python_version >= '3.5'
diff-cover==9.1.1; python_full_version >= '3.8.10' and python_full_version < '4.0.0'
dill==0.3.7; python_version >= '3.7'
dynaconf==3.2.2; python_version >= '3.8'
contextlib2==21.6.0
decorator==5.1.1
diff-cover==9.2.0; python_full_version >= '3.8.10' and python_full_version < '4.0.0'
dill==0.3.7
dynaconf==3.2.2
exceptiongroup==1.2.2; python_version < '3.11'
frozenlist==1.4.1; python_version >= '3.8'
gql[aiohttp]==3.4.1
graphql-core==3.2.3; python_version >= '3.6' and python_version < '4'
idna==3.4; python_version >= '3.5'
graphql-core==3.2.3
idna==3.4
iniconfig==2.0.0; python_version >= '3.7'
jinja2==3.1.4; python_version >= '3.7'
jmespath==1.0.1; python_version >= '3.7'
jsonlines==4.0.0; python_version >= '3.8'
jmespath==1.0.1
jsonlines==4.0.0
jsonpath-ng==1.5.3
jsonschema==4.19.0; python_version >= '3.8'
jsonschema==4.23.0
jsonschema-specifications==2023.12.1; python_version >= '3.8'
markupsafe==2.1.5; python_version >= '3.7'
multidict==6.0.5; python_version >= '3.7'
multidict==6.1.0; python_version >= '3.8'
nested-lookup==0.2.25
packaging==23.1; python_version >= '3.7'
panther-core==0.11.1
packaging==23.1
panther-core==0.11.2
pathspec==0.12.1; python_version >= '3.8'
pluggy==1.5.0; python_version >= '3.8'
ply==3.11
policyuniverse==1.5.1.20230817; python_version >= '3.7'
policyuniverse==1.5.1.20230817
pygments==2.18.0; python_version >= '3.8'
pytest==8.3.2; python_version >= '3.8'
python-dateutil==2.8.2; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
pytest==8.3.3; python_version >= '3.8'
python-dateutil==2.8.2
pyyaml==6.0.2; python_version >= '3.8'
referencing==0.35.1; python_version >= '3.8'
regex==2024.7.24; python_version >= '3.8'
requests==2.31.0; python_version >= '3.7'
requests==2.31.0
rpds-py==0.20.0; python_version >= '3.8'
ruamel.yaml==0.17.32; python_version >= '3'
ruamel.yaml.clib==0.2.7; python_version >= '3.5'
s3transfer==0.6.2; python_version >= '3.7'
ruamel.yaml==0.17.32
ruamel.yaml.clib==0.2.7
s3transfer==0.6.2
schema==0.7.5
semver==2.13.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
sqlfluff==2.3.1; python_version >= '3.7'
semver==2.13.0
six==1.16.0
sqlfluff==2.3.1
tblib==3.0.0; python_version >= '3.8'
toml==0.10.2; python_version < '3.11'
tomli==2.0.1; python_version < '3.11'
tqdm==4.66.5; python_version >= '3.7'
typing-extensions==4.7.1; python_version >= '3.7'
urllib3==1.26.18; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
wrapt==1.15.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
yarl==1.9.4; python_version >= '3.7'
typing-extensions==4.7.1
urllib3==1.26.18
wrapt==1.15.0
yarl==1.11.1; python_version >= '3.8'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"schema",
"semver",
"sqlfluff",
"panther-core==0.11.1",
"panther-core==0.11.2",
"typing-extensions",
"jsonlines",
]
Expand Down
Loading