nhost / cli

Nhost CLI
https://docs.nhost.io/development/cli/overview
MIT License
77 stars 28 forks source link

chore: update schema #913

Closed dbarrosop closed 2 months ago

dbarrosop commented 2 months ago

PR Type

Enhancement


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
example.go
Add Grafana SMTP Configuration                                                     

cmd/config/example.go
  • Added SMTP configuration to the Grafana section of the
    ConfigObservability struct
  • New fields include host, port, sender, user, and password for SMTP
    setup
  • +7/-0     
    models_gen.go
    Extend Grafana Configuration Models with SMTP                       

    nhostclient/graphql/models_gen.go
  • Added SMTP field to ConfigGrafana struct
  • Created new ConfigGrafanaSMTP struct with SMTP configuration fields
  • Added ConfigGrafanaSMTPUpdateInput struct for updating SMTP settings
  • Updated ConfigGrafanaUpdateInput to include SMTP update field
  • +20/-2   
    Tests
    local_test.go
    Update Test Configuration for Grafana SMTP                             

    cmd/configserver/local_test.go
  • Added a new Smtp field to the Grafana configuration in the test setup
  • Set the Smtp field to nil in the test configuration
  • +1/-0     
    Configuration changes
    config.go
    Update Default Config with Grafana SMTP Field                       

    project/config.go
  • Added Smtp field to the Grafana configuration in the default config
  • Set the Smtp field to nil in the default configuration
  • +1/-0     
    Dependencies
    go.mod
    Update Nhost Backend Dependency                                                   

    go.mod - Updated the `github.com/nhost/be` dependency to a newer version
    +1/-1     
    go.sum
    Update Dependency Checksums                                                           

    go.sum
  • Added a new version of the github.com/nhost/be dependency
  • Removed an old version of the same dependency
  • +2/-0     

    ๐Ÿ’ก PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    github-actions[bot] commented 2 months ago

    PR Reviewer Guide ๐Ÿ”

    โฑ๏ธ Estimated effort to review: 2 ๐Ÿ”ต๐Ÿ”ตโšชโšชโšช
    ๐Ÿงช No relevant tests
    ๐Ÿ”’ Security concerns

    Sensitive information exposure:
    The PR introduces SMTP configuration fields including username and password. While these are not directly exposed, care should be taken to ensure these sensitive credentials are properly secured and not logged or exposed in any way during runtime or in configuration files.
    โšก Key issues to review

    Hardcoded Credentials
    The example configuration contains hardcoded SMTP credentials, which is not a good practice for security reasons. Potential Type Mismatch
    The `Port` field in `ConfigGrafanaSMTP` is defined as `uint32`, which might not be compatible with all SMTP port configurations. Consider using `int` for more flexibility.
    github-actions[bot] commented 2 months ago

    PR Code Suggestions โœจ

    CategorySuggestion                                                                                                                                    Score
    Security
    Use environment variables for sensitive configuration data instead of hardcoding values ___ **Consider using environment variables or a secure configuration management system for
    sensitive information like SMTP credentials instead of hardcoding them in the
    example configuration.** [cmd/config/example.go [430-436]](https://github.com/nhost/cli/pull/913/files#diff-49de1d039dc29237e62d701aea07feeeb61ca2f6b2fd3c8ca5ac36c68e1396ecR430-R436) ```diff Smtp: &model.ConfigGrafanaSmtp{ - Host: "localhost", + Host: os.Getenv("GRAFANA_SMTP_HOST"), Port: 25, - Sender: "admin@localhost", - User: "smtpUser", - Password: "smtpPassword", + Sender: os.Getenv("GRAFANA_SMTP_SENDER"), + User: os.Getenv("GRAFANA_SMTP_USER"), + Password: os.Getenv("GRAFANA_SMTP_PASSWORD"), }, ```
    Suggestion importance[1-10]: 9 Why: This suggestion addresses a significant security concern by recommending the use of environment variables for sensitive data, which is a best practice for protecting credentials.
    9
    Enhancement
    Add validation tags to struct fields for improved data integrity ___ **Consider adding validation tags to the struct fields, especially for the Port field,
    to ensure that only valid values are accepted when unmarshaling JSON data.** [nhostclient/graphql/models_gen.go [583-589]](https://github.com/nhost/cli/pull/913/files#diff-6a0c1e8341663f25b1d5b4349be80026a1a2f25823bc7a71ad95a81096254d7dR583-R589) ```diff type ConfigGrafanaSMTP struct { - Host string `json:"host"` - Password string `json:"password"` - Port uint32 `json:"port"` - Sender string `json:"sender"` - User string `json:"user"` + Host string `json:"host" validate:"required"` + Password string `json:"password" validate:"required"` + Port uint16 `json:"port" validate:"required,min=1,max=65535"` + Sender string `json:"sender" validate:"required,email"` + User string `json:"user" validate:"required"` } ```
    Suggestion importance[1-10]: 7 Why: This suggestion enhances data validation and integrity, which is important for improving the robustness and reliability of the code, especially when dealing with user input or external data.
    7
    Best practice
    Use a more appropriate integer type for the port field ___ **Consider using a more specific type for the Port field in the ConfigGrafanaSMTP
    struct, such as uint16, which is sufficient for representing port numbers and more
    accurately reflects the valid range of port values.** [nhostclient/graphql/models_gen.go [583-589]](https://github.com/nhost/cli/pull/913/files#diff-6a0c1e8341663f25b1d5b4349be80026a1a2f25823bc7a71ad95a81096254d7dR583-R589) ```diff type ConfigGrafanaSMTP struct { Host string `json:"host"` Password string `json:"password"` - Port uint32 `json:"port"` + Port uint16 `json:"port"` Sender string `json:"sender"` User string `json:"user"` } ```
    Suggestion importance[1-10]: 6 Why: This suggestion improves code accuracy and type safety by using a more appropriate data type (uint16) for the port field, which is a minor but valuable improvement.
    6