skulpturenz / shared-resources

MIT License
0 stars 0 forks source link

fix: issue with order by on union with lowercase #256

Closed nmathew98 closed 1 week ago

github-actions[bot] commented 1 week ago

Title

fix: issue with order by on union with lowercase


PR Type

bug_fix


Description


Changes walkthrough ๐Ÿ“

Relevant files
Bug fix
kryptos.go
Fix query logic with CTE for environment variables             

kryptos/kryptos/kryptos.go
  • Added a Common Table Expression (CTE) named result to encapsulate the
    union query.
  • Modified the query to select from the result CTE.
  • Ensured the ORDER BY clause is applied to the final result set.
  • +11/-8   

    ๐Ÿ’ก PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    github-actions[bot] commented 1 week ago

    PR Reviewer Guide ๐Ÿ”

    Here are some key observations to aid the review process:

    โฑ๏ธ Estimated effort to review: 2 ๐Ÿ”ต๐Ÿ”ตโšชโšชโšช
    ๐Ÿ… Score: 85
    ๐Ÿงช No relevant tests
    ๐Ÿ”’ No security concerns identified
    โšก Recommended focus areas for review

    Logic Change
    The logic of the query has changed significantly with the addition of a new CTE and the union operation. This could affect the results returned by the function, and it should be validated against existing test cases to ensure correctness.
    github-actions[bot] commented 1 week ago

    PR Code Suggestions โœจ

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Security
    Improve security by parameterizing the SQL query to prevent injection attacks ___ **Ensure that the project_environments and global_environments queries are properly
    parameterized to prevent SQL injection vulnerabilities.** [kryptos/kryptos/kryptos.go [130]](https://github.com/skulpturenz/shared-resources/pull/256/files#diff-52d822dfcf5c61ba100975219c933d7bf9d7eb252bc0bbd2c88c408bb68855edR130-R130) ```diff global_environments AS (SELECT key, value FROM environments - WHERE deprecated = 0 AND project = '*'), + WHERE deprecated = 0 AND project = $2), ```
    Suggestion importance[1-10]: 8 Why: The suggestion addresses a potential SQL injection vulnerability by recommending parameterization, which is crucial for security in database queries.
    8
    Possible issue
    Enhance robustness by adding error handling for database operations ___ **Consider adding error handling for the SQL query execution to manage potential
    database errors gracefully.** [kryptos/kryptos/kryptos.go [143]](https://github.com/skulpturenz/shared-resources/pull/256/files#diff-52d822dfcf5c61ba100975219c933d7bf9d7eb252bc0bbd2c88c408bb68855edR143-R143) ```diff -queryWithSort := fmt.Sprintf(`%s ORDER BY key COLLATE NOCASE;`, query) +if _, err := db.Exec(queryWithSort); err != nil { + return err +} ```
    Suggestion importance[1-10]: 7 Why: Adding error handling for database operations is important for robustness, as it helps manage potential runtime errors gracefully, improving the overall reliability of the application.
    7
    github-actions[bot] commented 1 week ago

    :tropical_drink: preview on network/skulpture/shared-infrastructure

    Pulumi report
    Previewing update (shared-infrastructure)
    
    View Live: https://app.pulumi.com/skulpture/network/shared-infrastructure/previews/1c348f9b-6ae0-425f-9389-08e98e1d92cd
    
    @ Previewing update.....
    Downloading plugin gcp-7.38.0: starting
    Downloading plugin digitalocean-4.34.0: starting
    Downloading plugin digitalocean-4.34.0: done
    Downloading plugin gcp-7.38.0: done
    Installing plugin digitalocean-4.34.0: starting
    Installing plugin gcp-7.38.0: starting
    @ Previewing update....
    Installing plugin digitalocean-4.34.0: done
    Installing plugin gcp-7.38.0: done
    
    @ Previewing update....................................................................
    pulumi:pulumi:Stack network-shared-infrastructure running 
    @ Previewing update.....
    pulumi:pulumi:Stack network-shared-infrastructure  
    Resources:
    12 unchanged
    
    
    github-actions[bot] commented 1 week ago

    :tropical_drink: preview on rollout/skulpture/shared-rollout

    Pulumi report
    Previewing update (shared-rollout)
    
    View Live: https://app.pulumi.com/skulpture/rollout/shared-rollout/previews/0611e228-40b1-40e8-9342-d4f8c1058cdf
    
    @ Previewing update......
    Downloading plugin cloudflare-5.42.0: starting
    Downloading plugin gcp-7.38.0: starting
    Downloading plugin cloudflare-5.42.0: done
    Downloading plugin gcp-7.38.0: done
    Installing plugin cloudflare-5.42.0: starting
    Installing plugin gcp-7.38.0: starting
    @ Previewing update....
    Installing plugin cloudflare-5.42.0: done
    Installing plugin gcp-7.38.0: done
    
    @ Previewing update.........................................................................
    pulumi:pulumi:Stack rollout-shared-rollout running 
    pulumi:pulumi:Stack rollout-shared-rollout  
    Resources:
    4 unchanged
    
    
    github-actions[bot] commented 1 week ago

    :tropical_drink: preview on authnz/skulpture/shared-authnz

    Pulumi report
    Previewing update (shared-authnz)
    
    View Live: https://app.pulumi.com/skulpture/authnz/shared-authnz/previews/b1daa6c6-d155-455b-9869-1424d5562450
    
    @ Previewing update.......
    Downloading plugin gcp-7.38.0: starting
    Downloading plugin cloudflare-5.42.0: starting
    Downloading plugin cloudflare-5.42.0: done
    Installing plugin cloudflare-5.42.0: starting
    Downloading plugin gcp-7.38.0: done
    Installing plugin gcp-7.38.0: starting
    @ Previewing update....
    Installing plugin cloudflare-5.42.0: done
    Installing plugin gcp-7.38.0: done
    
    @ Previewing update...........................................................................
    pulumi:pulumi:Stack authnz-shared-authnz running 
    @ Previewing update....
    pulumi:pulumi:Stack authnz-shared-authnz  
    Resources:
    4 unchanged
    
    
    github-actions[bot] commented 1 week ago

    :tropical_drink: preview on telemetry/skulpture/shared-telemetry

    Pulumi report
    Previewing update (shared-telemetry)
    
    View Live: https://app.pulumi.com/skulpture/telemetry/shared-telemetry/previews/f4550e0d-4b6b-4f1e-9f09-70e86c858f71
    
    @ Previewing update......
    Downloading plugin cloudflare-5.42.0: starting
    Downloading plugin gcp-7.38.0: starting
    Downloading plugin cloudflare-5.42.0: done
    Downloading plugin gcp-7.38.0: done
    Installing plugin cloudflare-5.42.0: starting
    Installing plugin gcp-7.38.0: starting
    @ Previewing update....
    Installing plugin cloudflare-5.42.0: done
    Installing plugin gcp-7.38.0: done
    
    @ Previewing update...........................................................................
    pulumi:pulumi:Stack telemetry-shared-telemetry running 
    @ Previewing update....
    pulumi:pulumi:Stack telemetry-shared-telemetry  
    Resources:
    4 unchanged