Skip to content

Commit

Permalink
[#487] Refactor JSON output logic to switch from TypedDict to pydantic
Browse files Browse the repository at this point in the history
Fix some tests

Fix tests

Add tests and JSON schema

Fix requirements

Fix imports
  • Loading branch information
nabla-c0d3 committed Apr 12, 2021
1 parent 3a59a75 commit 226e89d
Show file tree
Hide file tree
Showing 58 changed files with 19,951 additions and 978 deletions.
34 changes: 16 additions & 18 deletions api_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,21 @@ def main() -> None:
print(f"\nResults for {server_scan_result.server_info.server_location.hostname}:")

# Scan commands that were run with no errors
try:
ssl2_result = server_scan_result.scan_commands_results[ScanCommand.SSL_2_0_CIPHER_SUITES]
ssl2_result = server_scan_result.scan_commands_results.ssl_2_0_cipher_suites
if ssl2_result:
print("\nAccepted cipher suites for SSL 2.0:")
for accepted_cipher_suite in ssl2_result.accepted_cipher_suites:
print(f"* {accepted_cipher_suite.cipher_suite.name}")
except KeyError:
pass

try:
certinfo_result = server_scan_result.scan_commands_results[ScanCommand.CERTIFICATE_INFO]
certinfo_result = server_scan_result.scan_commands_results.certificate_info
if certinfo_result:
print("\nCertificate info:")
for cert_deployment in certinfo_result.certificate_deployments:
print(f"Leaf certificate: \n{cert_deployment.received_certificate_chain_as_pem[0]}")
except KeyError:
pass

# Scan commands that were run with errors
for scan_command, error in server_scan_result.scan_commands_errors.items():
print(f"\nError when running {scan_command}:\n{error.exception_trace}")
for scan_command_error in server_scan_result.scan_commands_errors:
print(f"\nError when running {scan_command_error.scan_command}:\n{scan_command_error.exception_trace}")


if __name__ == "__main__":
Expand Down Expand Up @@ -99,13 +95,15 @@ def basic_example() -> None:
print(f"\nResults for {server_scan_result.server_info.server_location.hostname}:")

# SSL 2.0 results
ssl2_result = server_scan_result.scan_commands_results[ScanCommand.SSL_2_0_CIPHER_SUITES]
print("\nAccepted cipher suites for SSL 2.0:")
for accepted_cipher_suite in ssl2_result.accepted_cipher_suites:
print(f"* {accepted_cipher_suite.cipher_suite.name}")
ssl2_result = server_scan_result.scan_commands_results.ssl_2_0_cipher_suites
if ssl2_result:
print("\nAccepted cipher suites for SSL 2.0:")
for accepted_cipher_suite in ssl2_result.accepted_cipher_suites:
print(f"* {accepted_cipher_suite.cipher_suite.name}")

# Certificate info results
certinfo_result = server_scan_result.scan_commands_results[ScanCommand.CERTIFICATE_INFO]
print("\nCertificate info:")
for cert_deployment in certinfo_result.certificate_deployments:
print(f"Leaf certificate: \n{cert_deployment.received_certificate_chain_as_pem[0]}")
certinfo_result = server_scan_result.scan_commands_results.certificate_info
if certinfo_result:
print("\nCertificate info:")
for cert_deployment in certinfo_result.certificate_deployments:
print(f"Leaf certificate: \n{cert_deployment.received_certificate_chain_as_pem[0]}")
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = []
html_static_path = [] # type: ignore


# -- Options for HTMLHelp output ------------------------------------------
Expand Down
Loading

0 comments on commit 226e89d

Please sign in to comment.