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: [TT-13390] Silently skip loading bundle on managment node (#6739) #6743

Conversation

buger
Copy link
Member

@buger buger commented Dec 4, 2024

User description

TT-13390 Silently skip loading bundle on managment node (#6739)

User description

TT-13390
Summary Security feature introduced in v5.3.1 (skip loading API) introduces problems for Cloud users (OAuth APIs)
Type Bug Bug
Status In Dev
Points N/A
Labels '24Bugsmash, Adhoc, jira_escalated

Description

Related Issue

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

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

PR Type

Bug fix, Tests


Description

  • Updated the loadBundle function to silently skip loading bundles
    when the gateway instance is a management node.
  • Clarified the usage of the management_node configuration in the
    comments, specifying that it should always be set to false in pro
    environments.
  • Added a new test case to ensure that loadBundle behaves correctly
    when the gateway is a management node.

Changes walkthrough 📝

Relevant files
Documentation
config.go
Clarify `management_node` configuration usage in comments

config/config.go

  • Added clarification in the comments regarding the management_node
    configuration.
  • Specified that management_node should always be set to false in pro
    environments.
  • +3/-0     
    Bug fix
    coprocess_bundle.go
    Skip bundle loading on management nodes in `loadBundle`   

    gateway/coprocess_bundle.go

  • Updated loadBundle function to silently skip loading the bundle if the
    node is a management node.
  • +4/-0     
    Tests
    coprocess_bundle_test.go
    Add test for skipping bundle loading on management nodes 

    gateway/coprocess_bundle_test.go

  • Added a new test case to verify that loadBundle does not load bundles
    or throw errors when the gateway is a management node.
  • +17/-0   

    💡 PR-Agent usage: Comment /help "your question" on any pull
    request to receive relevant information


    PR Type

    Bug fix, Tests


    Description

    • Updated the loadBundle function to silently skip loading bundles when the gateway instance is a management node.
    • Clarified the usage of the management_node configuration in the comments, specifying that it should always be set to false in pro environments.
    • Added a new test case to ensure that loadBundle behaves correctly when the gateway is a management node.

    Changes walkthrough 📝

    Relevant files
    Documentation
    config.go
    Clarify `management_node` configuration usage in comments.

    config/config.go

  • Added clarification in comments about the management_node
    configuration.
  • Specified that management_node should always be set to false in pro
    environments.
  • +3/-0     
    Bug fix
    coprocess_bundle.go
    Skip bundle loading on management nodes in `loadBundle`. 

    gateway/coprocess_bundle.go

  • Updated the loadBundle function to silently skip loading bundles when
    the node is a management node.
  • +4/-0     
    Tests
    coprocess_bundle_test.go
    Add test for skipping bundle loading on management nodes.

    gateway/coprocess_bundle_test.go

  • Added a test case to verify that loadBundle does not load bundles or
    throw errors when the gateway is a management node.
  • +17/-0   

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    ### **User description**
    <details open>
    <summary><a href="https://tyktech.atlassian.net/browse/TT-13390"
    title="TT-13390" target="_blank">TT-13390</a></summary>
      <br />
      <table>
        <tr>
          <th>Summary</th>
    <td>Security feature introduced in v5.3.1 (skip loading API) introduces
    problems for Cloud users (OAuth APIs)</td>
        </tr>
        <tr>
          <th>Type</th>
          <td>
    <img alt="Bug"
    src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium"
    />
            Bug
          </td>
        </tr>
        <tr>
          <th>Status</th>
          <td>In Dev</td>
        </tr>
        <tr>
          <th>Points</th>
          <td>N/A</td>
        </tr>
        <tr>
          <th>Labels</th>
    <td><a
    href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20'24Bugsmash%20ORDER%20BY%20created%20DESC"
    title="'24Bugsmash">'24Bugsmash</a>, <a
    href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20Adhoc%20ORDER%20BY%20created%20DESC"
    title="Adhoc">Adhoc</a>, <a
    href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20jira_escalated%20ORDER%20BY%20created%20DESC"
    title="jira_escalated">jira_escalated</a></td>
        </tr>
      </table>
    </details>
    <!--
      do not remove this marker as it will break jira-lint's functionality.
      added_by_jira_lint
    -->
    
    ---
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
    <!-- Describe your changes in detail -->
    
    ## Related Issue
    https://tyktech.atlassian.net/browse/TT-13390
    
    ## 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
    
    
    ___
    
    ### **PR Type**
    Bug fix, Tests
    
    
    ___
    
    ### **Description**
    - Updated the `loadBundle` function to silently skip loading bundles
    when the gateway instance is a management node.
    - Clarified the usage of the `management_node` configuration in the
    comments, specifying that it should always be set to `false` in pro
    environments.
    - Added a new test case to ensure that `loadBundle` behaves correctly
    when the gateway is a management node.
    
    
    
    ___
    
    
    
    ### **Changes walkthrough** 📝
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Documentation</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>config.go</strong><dd><code>Clarify `management_node`
    configuration usage in comments</code></dd></summary>
    <hr>
    
    config/config.go
    
    <li>Added clarification in the comments regarding the
    <code>management_node</code> <br>configuration.<br> <li> Specified that
    <code>management_node</code> should always be set to <code>false</code>
    in pro <br>environments.<br>
    
    
    </details>
    
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6739/files#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17">+3/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    
    </tr>
    </table></td></tr><tr><td><strong>Bug fix</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>coprocess_bundle.go</strong><dd><code>Skip bundle
    loading on management nodes in `loadBundle`</code>&nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    gateway/coprocess_bundle.go
    
    <li>Updated <code>loadBundle</code> function to silently skip loading
    the bundle if the <br>node is a management node.<br>
    
    
    </details>
    
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6739/files#diff-72df0cbfd3765a5d0bff62196c11008596608a21a53dbb9c65bfc6f008dbfa29">+4/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    
    </tr>
    </table></td></tr><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>coprocess_bundle_test.go</strong><dd><code>Add test for
    skipping bundle loading on management nodes</code>&nbsp; </dd></summary>
    <hr>
    
    gateway/coprocess_bundle_test.go
    
    <li>Added a new test case to verify that <code>loadBundle</code> does
    not load bundles <br>or throw errors when the gateway is a management
    node.<br>
    
    
    </details>
    
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6739/files#diff-7fded1570c90f7be73d562f3ebcbb32fe4d50548dc5e959d8ecadddef13941fa">+17/-0</a>&nbsp;
    &nbsp; </td>
    
    </tr>
    </table></td></tr></tr></tbody></table>
    
    ___
    
    > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull
    request to receive relevant information
    
    (cherry picked from commit 7fbd718)
    @buger buger enabled auto-merge (squash) December 4, 2024 09:33
    Copy link
    Contributor

    github-actions bot commented Dec 4, 2024

    API Changes

    --- prev.txt	2024-12-04 09:33:47.487247098 +0000
    +++ current.txt	2024-12-04 09:33:44.563206221 +0000
    @@ -5046,6 +5046,9 @@
     	// Note:
     	//   If you set `db_app_conf_options.node_is_segmented` to `true` for multiple Gateway nodes, you should ensure that `management_node` is set to `false`.
     	//   This is to ensure visibility for the management node across all APIs.
    +	//
    +	//   For pro installations, `management_node` is not a valid configuration option.
    +	//   Always set `management_node` to `false` in pro environments.
     	ManagementNode bool `json:"management_node"`
     
     	// This is used as part of the RPC / Hybrid back-end configuration in a Tyk Enterprise installation and isn’t used anywhere else.

    Copy link
    Contributor

    github-actions bot commented Dec 4, 2024

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    6739 - Fully compliant

    Fully compliant requirements:

    • Update the loadBundle function to skip loading bundles on management nodes without errors.
    • Clarify the usage of the management_node configuration in comments.
    • Add tests to ensure the updated loadBundle function behaves as expected.
    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Logic Check
    Ensure that the new logic in loadBundle correctly identifies management nodes and skips loading without side effects.

    Copy link
    Contributor

    github-actions bot commented Dec 4, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    General
    Add logging for better traceability when skipping bundle loading on management nodes

    Ensure that the ManagementNode configuration check in loadBundle method logs a
    message when skipping the bundle loading for better traceability and debugging.

    gateway/coprocess_bundle.go [358-360]

     if gw.GetConfig().ManagementNode {
    +    log.Debug("Skipping bundle loading as the gateway instance is a management node.")
         return nil
     }
    Suggestion importance[1-10]: 7

    Why: Adding a debug log provides better traceability and debugging support, which is crucial for understanding the flow of operations in production environments. This change enhances the maintainability and observability of the code without altering its functionality.

    7

    @buger buger merged commit ffc8b61 into release-5.3 Dec 4, 2024
    34 of 38 checks passed
    @buger buger deleted the merge/release-5.3/7fbd718594aca9e2a06c70567282e1c3c3521f51 branch December 4, 2024 09:47
    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