Skip to content

Commit

Permalink
update metadata to only allow png images (#63)
Browse files Browse the repository at this point in the history
* update metadata to only allow png images

* update comment

* addressed comments
  • Loading branch information
shrimalmadhur authored Oct 31, 2023
1 parent 23a0dfd commit c396a15
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion types/operator_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ func isImageURL(urlString string) bool {
extension := filepath.Ext(path)

// List of common image file extensions
imageExtensions := []string{".jpg", ".jpeg", ".png", ".gif", ".bmp", ".svg", ".webp"}
// Only support PNG for now to reduce surface area of image validation
// We do NOT want to support formats like SVG since they can be used for javascript injection
// If we get pushback on only supporting png, we can support jpg, jpeg, gif, etc. later
imageExtensions := []string{".png"}

// Check if the extension is in the list of image extensions
for _, imgExt := range imageExtensions {
Expand Down
11 changes: 11 additions & 0 deletions types/operator_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ func TestOperatorMetadata(t *testing.T) {
},
wantErr: true,
},
{
name: "Invalid metadata - wrong image format",
metadata: OperatorMetadata{
Name: "test",
Description: "My operator",
Logo: "https://test.com/test.svg",
Twitter: "https://twitter.com/test",
Website: "https://test.com",
},
wantErr: true,
},
{
name: "Invalid metadata - description > 500 characters",
metadata: OperatorMetadata{
Expand Down

0 comments on commit c396a15

Please sign in to comment.