Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@0xdade
Copy link
Member

@0xdade 0xdade commented Jul 29, 2020

Now that agents can actually take screenshots of vnc again, they are being stored as jpg but the (poorly named) hashpath function hardcoded the extension to .png even though .jpg is the known format that vncsnapshot produces.

In the future we should update the screenshot stored in elastic to also contain the file extension, that way we could change the code to convert jpg to png or whatever else and the new documents would still be renderable instead of relying on the name of the service to map to extensions.

But this is just fixing the rendering for now. Trying not to make dramatic changes as we approach another tagged release.

@0xdade 0xdade added the server affecting natlas-server label Jul 29, 2020
@0xdade 0xdade requested a review from ajacques July 29, 2020 06:55
@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit 1f45dab and detected 0 issues on this pull request.

View more on Code Climate.

Comment on lines +15 to +18
def get_screenshot_path(inhash: str, service: str = "HTTP"):
ext_map = {"HTTP": ".png", "HTTPS": ".png", "VNC": ".jpg"}

return f"{inhash[0:2]}/{inhash[2:4]}/{inhash}{ext_map[service]}"
Copy link
Member

Choose a reason for hiding this comment

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

I understand this is a short-term fix since you mentioned you were going to add a better strategy, but we shouldn't make assumptions like this in the rendering logic just in case we change formats.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, this just brings the rendering logic in line with the logic in screenshot processing:

for item in screenshots:
if item["service"] == "VNC":
file_ext = ".jpg"
else: # Handles http, https files from aquatone/chromium-headless
file_ext = ".png"

With the agent rearchitecture we'll probably lose backwards compatibility and it's the perfect time to make big changes to the data model too for a 0.7.0 release.

@0xdade 0xdade merged commit 424ed99 into natlas:main Jul 29, 2020
@0xdade 0xdade deleted the vnc_rendering branch July 31, 2020 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

server affecting natlas-server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants