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

update metadata to only allow png images #63

Merged
merged 3 commits into from
Oct 31, 2023
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
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
Loading