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

Create reports_definition.py for launching reports from pyTenable #656

Merged
merged 25 commits into from
Nov 21, 2024

Conversation

samwmarsh
Copy link
Contributor

@samwmarsh samwmarsh commented Dec 7, 2022

Tenable SC launch reports using ID in pytenable

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • Python Version(s) Tested:
  • Tenable.sc version (if necessary):

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Tenable SC launch reports using ID in pytenable
@samwmarsh samwmarsh requested a review from a team December 7, 2022 13:55
@samwmarsh samwmarsh changed the title Create reports_definition.py Create reports_definition.py for launching reports from pyTenable Dec 7, 2022
Copy link
Collaborator

@aseemsavio aseemsavio left a comment

Choose a reason for hiding this comment

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

Could you provide information on how this was tested? You can refer to existing tests in this directory tests/sc/.

@samwmarsh
Copy link
Contributor Author

Could you provide information on how this was tested? You can refer to existing tests in this directory tests/sc/.

Hey @aseemsavio , I'm not sure what you're asking me to do with the tests/sc/ folder but that's going to be me not understanding what it is/does. I've tested this locally against an internal version of tenable.sc and it works as intended for launching reportDefinitions, which can then be downloaded with the report endpoint (having returned a report ID).

@aseemsavio
Copy link
Collaborator

Hey @samwmarsh no problem at all! We include tests that confirms the behaviour of a new feature we're adding with the respective pull request. Give me some time, I'll let you know the changes required.

@samwmarsh
Copy link
Contributor Author

@aseemsavio all changes merged thanks

@samwmarsh
Copy link
Contributor Author

@SteveMcGrath that's all sorted, anything blocking this merge now?

@SteveMcGrath
Copy link
Contributor

I'd say there are still some issues just looking at the test suite.

https://github.com/tenable/pyTenable/actions/runs/3881092089/jobs/6619727711#step:5:258

@samwmarsh samwmarsh requested a review from a team as a code owner May 21, 2024 14:13
@samwmarsh
Copy link
Contributor Author

@SteveMcGrath sorry for the delay on this one, I think I've resolved the test suite issues - seemed to be an issue with typo between file name and imports.

@samwmarsh
Copy link
Contributor Author

@SteveMcGrath anything this is waiting on?

Copy link
Contributor

@SteveMcGrath SteveMcGrath left a comment

Choose a reason for hiding this comment

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

Aside from missing unit tests, looks good.

@SteveMcGrath
Copy link
Contributor

Apologize for the delay, this one got pushed to the bottom of the stack. if you're willing to write the unit tests, I have no issues getting this approved.

@samwmarsh
Copy link
Contributor Author

Not a python dev by any means but hows that? all checks seem happy.

@SteveMcGrath
Copy link
Contributor

The two tests you wrote look great, just need a test with a success as well. Not anything crazy, we just need to assert that were getting a valid response. maybe check that the ID exists in the response and it should be ready to merge.

@samwmarsh
Copy link
Contributor Author

Something like that?

@samwmarsh
Copy link
Contributor Author

FAILED tests/sc/test_report_definition.py::test_report_definition_launch_success - requests.exceptions.ConnectionError: HTTPSConnectionPool(host='securitycenter.home.cugnet.net', port=443): Max retries exceeded with url: /rest/reportDefinition/1/launch (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f63a12b2990>: Failed to establish a new connection: [Errno -2] Name or service not known'))

I copied this from a different test, is this ok or is there a host value this should be to pass?

@samwmarsh
Copy link
Contributor Author

Thanks @SteveMcGrath, apologies I've not got access to .sc from my public github location so it was guesswork based off of the api docs!

@SteveMcGrath
Copy link
Contributor

Not a problem, it appeared that the JSON you posted in the cassette wasn't valid, so i tweaked it.

@SteveMcGrath SteveMcGrath merged commit 7e13674 into tenable:main Nov 21, 2024
9 checks passed
@samwmarsh samwmarsh deleted the patch-1 branch November 21, 2024 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants