Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Tags saved during site save#26

Open
derpadoo wants to merge 1 commit into
rapid7:masterfrom
derpadoo:issue-22
Open

Tags saved during site save#26
derpadoo wants to merge 1 commit into
rapid7:masterfrom
derpadoo:issue-22

Conversation

@derpadoo

@derpadoo derpadoo commented Sep 5, 2017

Copy link
Copy Markdown
Contributor

Tags were not saved during a site save.

Description

The API returns a custom date/time format for tag's creation date that is converted into epoch and sent back. Discovered that "Built-In" tags do not return the default tag color so that is added. The "Built-In" tags also have a CREATOR_USER_ID of "0" which was throwing an exception. This block of code fixes these issues so the site info can be submitted successfully.

Motivation and Context

Fixes #22

How Has This Been Tested?

Can't...dev environment is still broken.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

@gschneider-r7 gschneider-r7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall looks good, just minor changes requested to tighten things up. I am a bit dissatisfied with the Nexpose API needing so many workarounds here, so I might try to get a fix for that into the product sometime soon and then we could improve this more after that. I won't hold up the merge based on pending product changes, though.

Comment thread nexpose/nexpose_site.py
for tag in self.tags:
for tag_data in tag:
tag_data_name = get_attribute(tag_data, 'name')
tag_data_value = get_attribute(tag_data, 'value')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Per flake8 output, tag_data_value is never used. Should probably be used in place of the calls to get_attribute(tag_data, 'value') in the below if blocks since the value shouldn't change until the name matches a condition.

Comment thread nexpose/nexpose_site.py
# CREATION_DATE must be in epoch time.
if tag_data_name == 'CREATION_DATE':
creation_date_value = get_attribute(tag_data, 'value')
creation_date_as_datetime = datetime.datetime.strptime(creation_date_value, '%a %b %d %H:%M:%S %Z %Y')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The date format string could be extracted to a constant, but I don't think it's a big deal.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Saving a site with tags tries to pass CREATION_DATE and throws an exception

2 participants