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

[APP-7307]: Remove logo file path manipulation in CLI for OrganizationSetLogo. #4651

Merged
merged 2 commits into from
Dec 22, 2024

Conversation

maxhorowitz
Copy link
Member

@maxhorowitz maxhorowitz requested a review from a team as a code owner December 20, 2024 18:03
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Dec 20, 2024
@maxhorowitz
Copy link
Member Author

Validated it works:

maxhorowitz at stingray in ~/dev/rdk on APP-7307 [$]
$ go run cli/viam/main.go organization logo set --org-id="********" --logo-path="../../Desktop/jeep.png"
Error: Logo file is too large: 217947 bytes (max size is 200KB)
exit status 1

@maxhorowitz maxhorowitz requested a review from jr22 December 20, 2024 18:07
@@ -345,15 +344,7 @@ func (c *viamClient) organizationLogoSetAction(cCtx *cli.Context, orgID, logoFil
if err := c.ensureLoggedIn(); err != nil {
return err
}

// determine whether this is a valid file path on the local system
logoFilePath = strings.ToLower(filepath.Clean(logoFilePath))
Copy link
Member

Choose a reason for hiding this comment

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

can we keep the filepath.Clean?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

cli/client.go Outdated
}

logoFile, err := os.Open(logoFilePath)
logoFile, err := os.Open(logoFilePath) //nolint:gosec
Copy link
Member

Choose a reason for hiding this comment

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

what is the linter complaining about for security

Copy link
Member Author

Choose a reason for hiding this comment

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

If I add filepath.Clean maybe it won't be necessary - but yeah really didn't know what / why needed

Comment on lines -352 to -353
if len(logoFilePath) < 5 || logoFilePath[len(logoFilePath)-4:] != ".png" {
return errors.Errorf("%s is not a valid .png file path", logoFilePath)
Copy link
Member

Choose a reason for hiding this comment

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

why remove? because it might be a png but not have png ending?

Copy link
Member

Choose a reason for hiding this comment

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

we do this checking server side so agree we dont necessarily need it here

Copy link
Member Author

Choose a reason for hiding this comment

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

Duplicated validation thats not as thorough as what we have in the BE because of that reason

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Dec 20, 2024
@maxhorowitz maxhorowitz requested a review from jr22 December 20, 2024 18:16
@maxhorowitz maxhorowitz merged commit 5d987fd into viamrobotics:main Dec 22, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants