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

[Tenable Vuln Management] fix: last_scan_target attribute inconsistent presence in API response should be handled gracefully #3547

Conversation

flavienSindou
Copy link
Contributor

Proposed changes

  • Make last_target_scan field optional in tenable API response validator

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality using different use cases
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

https://www.notion.so/filigran/Tenable-Vuln-Management-Tenable-Breaking-API-Changes-1a48fce17f2a807e8275fd416f7df756?pvs=4#1ab8fce17f2a8004b503fb022ed808db

@flavienSindou flavienSindou self-assigned this Mar 3, 2025
@flavienSindou flavienSindou added bug use for describing something not working as expected filigran team use to identify PR from the Filigran team critical use to identify critical bug to fix ASAP labels Mar 3, 2025
Copy link
Member

@Powlinett Powlinett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to remove last_scan_target from assets in tenable_api_response.json and I got this error:

        with pytest.warns(ValidationWarning):
>           _ = VulnerabilityFinding.model_validate(tenable_api_response_1_report)
E           pydantic_core._pydantic_core.ValidationError: 1 validation error for VulnerabilityFinding
E           asset.last_scan_target
E             Field required [type=missing, input_value={'device_type': 'hypervis...00000', 'tracked': True}, input_type=dict]
E               For further information visit https://errors.pydantic.dev/2.10/v/missing

tests\test_models\test_tenable.py:76: ValidationError

I think it's missing a default value, see my comment.

@@ -286,7 +286,7 @@ class Asset(FrozenBaseModelWithWarnedExtra):
..., description="The ID of the network the asset belongs to."
)
tracked: bool = Field(..., description="Indicates if the asset is being tracked.")
last_scan_target: str = Field(
last_scan_target: Optional[str] = Field(
...,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default should be set to None, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right ! Thank you for your remark !

@Powlinett Powlinett dismissed their stale review March 4, 2025 08:43

requested changes applied

@flavienSindou flavienSindou merged commit 6f7ddcf into master Mar 4, 2025
4 checks passed
@flavienSindou flavienSindou deleted the bug/3542-tenable-vuln-management-last_scan_target-attribute-inconsistent-presence-in-api-response-should-be-handled-gracefully branch March 4, 2025 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug use for describing something not working as expected critical use to identify critical bug to fix ASAP filigran team use to identify PR from the Filigran team
Projects
None yet
2 participants