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

MM-56989: Sanitize collected MM config #702

Merged
merged 2 commits into from
Mar 6, 2024

Conversation

agarciamontoro
Copy link
Member

Summary

This PR adds an optional step for all files collected during the collect command: a func(input []bytes) ([]bytes, error) that is called when the corresponding file is downloaded from the instance and before adding it to the collection.

This is used for all app nodes to sanitize the config retrieved from them. As an example, this is an excerpt of the FileSettings section in the generated file:

  "FileSettings": {
    "PublicLinkSalt": "********************************",
    "InitialFont": "nunito-bold.ttf",
    "AmazonS3AccessKeyId": "AKIA2TV23Z44BXMGHWOE",
    "AmazonS3SecretAccessKey": "********************************",
    "AmazonS3Bucket": "mm569896989agm.s3bucket",
    "AmazonS3PathPrefix": "",
  },

Ticket Link

https://mattermost.atlassian.net/browse/MM-56989

Use it to sanitize MM config
@agarciamontoro agarciamontoro added the 2: Dev Review Requires review by a core committer label Mar 5, 2024
addInfo(name, "/opt/mattermost/logs/mattermost.log", true, nil)
addInfo(name, "/opt/mattermost/config/config.json", false, func(input []byte) ([]byte, error) {
var cfg model.Config
json.Unmarshal(input, &cfg)
Copy link
Member

Choose a reason for hiding this comment

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

Shall we check errors 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.

Ah, lol, yes 😂 Thanks!

@agarciamontoro agarciamontoro requested a review from isacikgoz March 5, 2024 17:34
Copy link
Member

@isacikgoz isacikgoz left a comment

Choose a reason for hiding this comment

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

Nice :)

@agarciamontoro agarciamontoro added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Mar 6, 2024
@agarciamontoro
Copy link
Member Author

Merging. This was tested in a fresh deployment and it worked as expected.

@agarciamontoro agarciamontoro merged commit e1fdc14 into master Mar 6, 2024
1 check passed
@agarciamontoro agarciamontoro deleted the MM-56989.sanitize.config branch March 6, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants