Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions dvc/render/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ def _write_image(
img_path = os.path.join(
static, f"{revision}_{filename.replace(os.sep, '_')}"
)
rel_img_path = relpath(img_path, page_dir_path)
with open(img_path, "wb") as fd:
fd.write(image_data)
return """
<div>
<p>{title}</p>
<img src="{src}">
</div>""".format(
title=revision, src=rel_img_path
title=revision, src=(relpath(img_path, page_dir_path))
Comment on lines 38 to +40
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what this refactoring does πŸ˜‹

My feedback (#6431 (review)) was that you could inject HTML code via revision, which is a CLI input I think (can be any string). Of course it get's prepended with static/ so maybe that neutralizes any script, not sure.

Still the best practice would be to validate the input or at least sanitize the HTML output? Or maybe I'm exaggerating here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jorgeorpinel I am not sure I understand. Do you mean to pass some HTML via revision CLI argument? What would this HTML be and what would be its purpose?

Copy link
Contributor

@jorgeorpinel jorgeorpinel Oct 5, 2021

Choose a reason for hiding this comment

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

Sorry for the delay @pared .

Do you mean to pass some HTML via revision CLI argument?

Yes. Well, probably JS mainly.

What would this HTML be and what would be its purpose?

A malicious <script>.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so in the beginning, I did not understand the problem. Hmm, it seems that you are right here.

On the other hand, I think that if one is able to use dvc plots show, he/she can edit the webpage in-place (since they have write permission anyway), so the modification can be done without help of DVC.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK @pared ! Up to you

)

def _convert(self, path: "StrPath"):
Expand Down
2 changes: 1 addition & 1 deletion dvc/render/vega.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PlotDataStructureError(DvcException):
def __init__(self):
super().__init__(
"Plot data extraction failed. Please see "
"https://man.dvc.org/plot for supported data formats."
"https://man.dvc.org/plots for supported data formats."
)


Expand Down