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

Merging to release-5.3.0: [TT-11405] Updating JSON tags and field names for TLS max and min versions (#6078) #6083

Conversation

buger
Copy link
Member

@buger buger commented Feb 29, 2024

User description

[TT-11405] Updating JSON tags and field names for TLS max and min versions (#6078)

User description

Description

Updating JSON tags and field names for TLS max and min versions.

https://tyktech.atlassian.net/browse/TT-11405

Related Issue

https://tyktech.slack.com/archives/C02AS4BP5HN/p1709041100516449

Motivation and Context

How This Has Been Tested

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing
    functionality to change)
  • Refactoring or add test (improvements in base code or adds test
    coverage to functionality)

Checklist

  • I ensured that the documentation is up to date
  • I explained why this PR updates go.mod in detail with reasoning
    why it's required
  • I would like a code coverage CI quality gate exception and have
    explained why

Type

enhancement


Description

  • Updated JSON tags and field names related to TLS version configuration
    across multiple files to improve clarity and consistency.
  • Renamed MinVersion and MaxVersion to TLSMinVersion and
    TLSMaxVersion in HttpServerOptionsConfig for better readability.
  • Adjusted references in the TLS configuration setup in various parts of
    the codebase to align with the new field names.
  • Ensured TLS version consistency and updated the default TLS max
    version to VersionTLS12 in the gateway server configuration.

Changes walkthrough

Relevant files
Enhancement
config.go
Update TLS version field names and JSON tags                         

config/config.go

  • Updated JSON tags for MaxVersion and MinVersion to tls_max_version and
    tls_min_version respectively in StorageOptionsConf.
  • Renamed fields MinVersion and MaxVersion to TLSMinVersion and
    TLSMaxVersion in HttpServerOptionsConfig.
  • +4/-4     
    dashboard_register.go
    Align TLS version configuration references                             

    gateway/dashboard_register.go

  • Updated references from MinVersion and MaxVersion to TLSMinVersion and
    TLSMaxVersion in the TLS configuration.
  • +2/-2     
    proxy_muxer.go
    Update TLS version configuration in proxy muxer                   

    gateway/proxy_muxer.go

  • Adjusted TLS configuration to use the new TLSMinVersion and
    TLSMaxVersion fields.
  • +2/-2     
    rpc_storage_handler.go
    Update RPC storage handler TLS version configuration         

    gateway/rpc_storage_handler.go

  • Updated RPC configuration to use TLSMinVersion and TLSMaxVersion for
    SSL version control.
  • +2/-2     
    server.go
    Enforce TLS version consistency and update defaults           

    gateway/server.go

  • Ensured TLS version consistency and updated the default TLS max
    version to VersionTLS12.
  • Updated checks and assignments to use TLSMinVersion and TLSMaxVersion.
  • +4/-4     

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


    Type

    enhancement


    Description

    • Renamed JSON tags and field names for TLS max and min versions to TLSMaxVersion and TLSMinVersion respectively.
    • Updated all references in the codebase to match the new field names.

    Changes walkthrough

    Relevant files
    Enhancement
    config.go
    Update JSON tags and field names for TLS versions               

    config/config.go

  • Renamed MaxVersion to TLSMaxVersion.
  • Renamed MinVersion to TLSMinVersion.
  • +2/-2     
    connection_handler.go
    Adapt TLS version field references in connection handler 

    storage/connection_handler.go

  • Updated references from MaxVersion to TLSMaxVersion.
  • Updated references from MinVersion to TLSMinVersion.
  • +2/-2     

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

    …sions (#6078)
    
    ## **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    Updating JSON tags and field names for TLS max and min versions. 
    
    https://tyktech.atlassian.net/browse/TT-11405
    <!-- Describe your changes in detail -->
    
    ## Related Issue
    https://tyktech.slack.com/archives/C02AS4BP5HN/p1709041100516449
    <!-- This project only accepts pull requests related to open issues. -->
    <!-- If suggesting a new feature or change, please discuss it in an
    issue first. -->
    <!-- If fixing a bug, there should be an issue describing it with steps
    to reproduce. -->
    <!-- OSS: Please link to the issue here. Tyk: please create/link the
    JIRA ticket. -->
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- Please describe in detail how you tested your changes -->
    <!-- Include details of your testing environment, and the tests -->
    <!-- you ran to see how your change affects other areas of the code,
    etc. -->
    <!-- This information is helpful for reviewers and QA. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- What types of changes does your code introduce? Put an `x` in all
    the boxes that apply: -->
    
    - [ ] Bug fix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing
    functionality to change)
    - [ ] Refactoring or add test (improvements in base code or adds test
    coverage to functionality)
    
    ## Checklist
    
    <!-- Go over all the following points, and put an `x` in all the boxes
    that apply -->
    <!-- If there are no documentation updates required, mark the item as
    checked. -->
    <!-- Raise up any additional concerns not covered by the checklist. -->
    
    - [ ] I ensured that the documentation is up to date
    - [ ] I explained why this PR updates go.mod in detail with reasoning
    why it's required
    - [ ] I would like a code coverage CI quality gate exception and have
    explained why
    
    
    ___
    
    ## **Type**
    enhancement
    
    
    ___
    
    ## **Description**
    - Updated JSON tags and field names related to TLS version configuration
    across multiple files to improve clarity and consistency.
    - Renamed `MinVersion` and `MaxVersion` to `TLSMinVersion` and
    `TLSMaxVersion` in `HttpServerOptionsConfig` for better readability.
    - Adjusted references in the TLS configuration setup in various parts of
    the codebase to align with the new field names.
    - Ensured TLS version consistency and updated the default TLS max
    version to `VersionTLS12` in the gateway server configuration.
    
    
    ___
    
    
    
    ## **Changes walkthrough**
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>config.go</strong><dd><code>Update TLS version field
    names and JSON tags</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    config/config.go
    <li>Updated JSON tags for <code>MaxVersion</code> and
    <code>MinVersion</code> to <code>tls_max_version</code> and
    <br><code>tls_min_version</code> respectively in
    <code>StorageOptionsConf</code>.<br> <li> Renamed fields
    <code>MinVersion</code> and <code>MaxVersion</code> to
    <code>TLSMinVersion</code> and <br><code>TLSMaxVersion</code> in
    <code>HttpServerOptionsConfig</code>.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://pull/6078/files#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17">+4/-4</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>dashboard_register.go</strong><dd><code>Align TLS
    version configuration references</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    gateway/dashboard_register.go
    <li>Updated references from <code>MinVersion</code> and
    <code>MaxVersion</code> to <code>TLSMinVersion</code> and
    <br><code>TLSMaxVersion</code> in the TLS configuration.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://pull/6078/files#diff-f504c88b3d2fa3b56b74c252aab41a934156879ef1150d33714225749e6cc94c">+2/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>proxy_muxer.go</strong><dd><code>Update TLS version
    configuration in proxy muxer</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/proxy_muxer.go
    <li>Adjusted TLS configuration to use the new <code>TLSMinVersion</code>
    and <br><code>TLSMaxVersion</code> fields.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://pull/6078/files#diff-89fb6731880400cb95ba8860c935a308de5f55aaa41aa2c76abf3ee4773d7a87">+2/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>rpc_storage_handler.go</strong><dd><code>Update RPC
    storage handler TLS version configuration</code>&nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/rpc_storage_handler.go
    <li>Updated RPC configuration to use <code>TLSMinVersion</code> and
    <code>TLSMaxVersion</code> for <br>SSL version control.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://pull/6078/files#diff-8875f75b602664c44b62b67a4da41d748124ad270573a44db4ec977ee5d68021">+2/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>server.go</strong><dd><code>Enforce TLS version
    consistency and update defaults</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    gateway/server.go
    <li>Ensured TLS version consistency and updated the default TLS max
    <br>version to <code>VersionTLS12</code>.<br> <li> Updated checks and
    assignments to use <code>TLSMinVersion</code> and
    <code>TLSMaxVersion</code>.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://pull/6078/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+4/-4</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr></tr></tbody></table>
    
    ___
    
    > ✨ **PR-Agent usage**:
    >Comment `/help` on the PR to get a list of all available PR-Agent tools
    and their descriptions
    
    (cherry picked from commit 6dac26d)
    Copy link
    Contributor

    PR Description updated to latest commit (4d237e1)

    Copy link
    Contributor

    API Changes

    --- prev.txt	2024-02-29 13:44:59.536410939 +0000
    +++ current.txt	2024-02-29 13:44:56.728420631 +0000
    @@ -5747,11 +5747,11 @@
     	// Maximum TLS version that is supported.
     	// Options: ["1.0", "1.1", "1.2", "1.3"].
     	// Defaults to "1.3".
    -	MaxVersion string `json:"max_version"`
    +	TLSMaxVersion string `json:"tls_max_version"`
     	// Minimum TLS version that is supported.
     	// Options: ["1.0", "1.1", "1.2", "1.3"].
     	// Defaults to "1.2".
    -	MinVersion string `json:"min_version"`
    +	TLSMinVersion string `json:"tls_min_version"`
     }
     
     func (config *StorageOptionsConf) HostAddrs() (addrs []string)

    Copy link
    Contributor

    PR Review

    ⏱️ Estimated effort to review [1-5]

    2, because the changes are straightforward and localized to specific fields in the configuration and connection handler. The modifications involve renaming fields and updating their references, which is relatively simple but requires careful attention to detail to ensure all instances are correctly updated.

    🧪 Relevant tests

    No

    🔍 Possible issues

    The renaming of MaxVersion and MinVersion to TLSMaxVersion and TLSMinVersion might cause compatibility issues with existing configurations that use the old field names. It's important to ensure backward compatibility or provide a clear migration path.

    There's a potential issue if other parts of the codebase reference the old field names (MaxVersion and MinVersion) that haven't been updated in this PR. This could lead to runtime errors or misconfigurations.

    🔒 Security concerns

    No

    Code feedback:
    relevant fileconfig/config.go
    suggestion      

    Consider implementing a backward compatibility mechanism for MaxVersion and MinVersion. This could involve temporarily supporting both the old and new field names to avoid breaking changes for users updating to the new version. This can be achieved by using custom JSON unmarshalling or providing a migration tool/script. [important]

    relevant lineTLSMaxVersion string `json:"tls_max_version"`

    relevant filestorage/connection_handler.go
    suggestion      

    Ensure that all references to MaxVersion and MinVersion throughout the entire codebase, including tests and documentation, are updated to TLSMaxVersion and TLSMinVersion to maintain consistency and avoid potential runtime errors. [important]

    relevant lineMaxVersion: cfg.TLSMaxVersion,


    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
    When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:

    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    

    With a configuration file, use the following template:

    [pr_reviewer]
    some_config1=...
    some_config2=...
    
    Utilizing extra instructions

    The review tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize.

    Examples for extra instructions:

    [pr_reviewer] # /review #
    extra_instructions="""
    In the 'possible issues' section, emphasize the following:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    How to enable\disable automation
    • When you first install PR-Agent app, the default mode for the review tool is:
    pr_commands = ["/review", ...]
    

    meaning the review tool will run automatically on every PR, with the default configuration.
    Edit this field to enable/disable the tool, or to change the used configurations

    Auto-labels

    The review tool can auto-generate two specific types of labels for a PR:

    • a possible security issue label, that detects possible security issues (enable_review_labels_security flag)
    • a Review effort [1-5]: x label, where x is the estimated effort to review the PR (enable_review_labels_effort flag)
    Extra sub-tools

    The review tool provides a collection of possible feedbacks about a PR.
    It is recommended to review the possible options, and choose the ones relevant for your use case.
    Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example:
    require_score_review, require_soc2_ticket, and more.

    Auto-approve PRs

    By invoking:

    /review auto_approve
    

    The tool will automatically approve the PR, and add a comment with the approval.

    To ensure safety, the auto-approval feature is disabled by default. To enable auto-approval, you need to actively set in a pre-defined configuration file the following:

    [pr_reviewer]
    enable_auto_approval = true
    

    (this specific flag cannot be set with a command line argument, only in the configuration file, committed to the repository)

    You can also enable auto-approval only if the PR meets certain requirements, such as that the estimated_review_effort is equal or below a certain threshold, by adjusting the flag:

    [pr_reviewer]
    maximal_review_effort = 5
    
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the review usage page for a comprehensive guide on using this tool.

    Copy link
    Contributor

    github-actions bot commented Feb 29, 2024

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Enhancement
    Validate TLS version fields to ensure they contain valid values.

    Consider validating the TLSMaxVersion and TLSMinVersion fields to ensure they contain
    valid TLS version strings. This can be done by implementing a custom unmarshaler or by
    adding a validation method that is called after the configuration is loaded.

    config/config.go [154-158]

    -TLSMaxVersion string `json:"tls_max_version"`
    -TLSMinVersion string `json:"tls_min_version"`
    +// Example validation method
    +func (c *StorageOptionsConf) ValidateTLSVersions() error {
    +  validVersions := map[string]bool{"1.0": true, "1.1": true, "1.2": true, "1.3": true}
    +  if _, ok := validVersions[c.TLSMaxVersion]; !ok {
    +    return fmt.Errorf("invalid TLSMaxVersion: %s", c.TLSMaxVersion)
    +  }
    +  if _, ok := validVersions[c.TLSMinVersion]; !ok {
    +    return fmt.Errorf("invalid TLSMinVersion: %s", c.TLSMinVersion)
    +  }
    +  return nil
    +}
     
    Convert TLS version strings to crypto/tls package constants.

    Ensure that the TLS version strings (TLSMinVersion and TLSMaxVersion) from the
    configuration are correctly converted to the corresponding constants in the crypto/tls
    package before being used. This conversion is necessary because the crypto/tls package
    does not use string representations for TLS versions.

    storage/connection_handler.go [276-277]

    -MinVersion:         cfg.TLSMinVersion,
    -MaxVersion:         cfg.TLSMaxVersion,
    +// Example conversion (assuming a conversion function exists)
    +MinVersion:         convertTLSVersion(cfg.TLSMinVersion),
    +MaxVersion:         convertTLSVersion(cfg.TLSMaxVersion),
     

    ✨ Improve tool usage guide:

    Overview:
    The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.
    When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:

    /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
    

    With a configuration file, use the following template:

    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    
    Enabling\disabling automation

    When you first install the app, the default mode for the improve tool is:

    pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...]
    

    meaning the improve tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.

    Utilizing extra instructions

    Extra instructions are very important for the improve tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on.

    Examples for extra instructions:

    [pr_code_suggestions] # /improve #
    extra_instructions="""
    Emphasize the following aspects:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    A note on code suggestions quality
    • While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically.
    • Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base.
    • Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the custom suggestions 💎 tool
    • With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the improve usage page for a more comprehensive guide on using this tool.

    @mativm02 mativm02 merged commit 9f08de5 into release-5.3.0 Feb 29, 2024
    7 checks passed
    @mativm02 mativm02 deleted the merge/release-5.3.0/6dac26dac0ac3aeadc29578bc90c57cce77031c9 branch February 29, 2024 13:47
    Copy link

    @buger
    Copy link
    Member Author

    buger commented Feb 29, 2024

    API tests result - postgres15-sha256 env: success
    Branch used: refs/tags/v5.3.0-rc5
    Commit: 9f08de5
    Triggered by: push (@nerdydread)
    Execution page

    @buger
    Copy link
    Member Author

    buger commented Feb 29, 2024

    API tests result - mongo44-sha256 env: success
    Branch used: refs/tags/v5.3.0-rc5
    Commit: 9f08de5
    Triggered by: push (@nerdydread)
    Execution page

    @buger
    Copy link
    Member Author

    buger commented Feb 29, 2024

    API tests result - postgres15-murmur64 env: success
    Branch used: refs/tags/v5.3.0-rc5
    Commit: 9f08de5
    Triggered by: push (@nerdydread)
    Execution page

    @buger
    Copy link
    Member Author

    buger commented Feb 29, 2024

    API tests result - mongo44-murmur64 env: success
    Branch used: refs/tags/v5.3.0-rc5
    Commit: 9f08de5
    Triggered by: push (@nerdydread)
    Execution page

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants