Skip to content

Releases: kubescape/node-agent

Release v0.2.12

21 Feb 11:52
006bac6
Compare
Choose a tag to compare

Type

enhancement, bug_fix


Description

  • Implemented a retry mechanism with exponential backoff in startApplicationProfiling to ensure instanceID is set before monitoring starts. This addresses potential race conditions where monitoring could start before the instanceID is available.
  • Refactored ensureInstanceID function to improve error handling, removing the context parameter and adding detailed error messages for each failure point.
  • Updated the Golang base image in the Dockerfile to golang:1.21-bullseye, simplifying the version specification.

Changes walkthrough

Relevant files
Enhancement
applicationprofile_manager.go
Refactor ensureInstanceID Function and Implement Retry Mechanism

pkg/applicationprofilemanager/v1/applicationprofile_manager.go

  • Removed context parameter from ensureInstanceID function.
  • Added error handling to ensureInstanceID with detailed error messages.
  • Implemented exponential backoff retry mechanism in
    startApplicationProfiling to ensure instanceID is set before
    monitoring starts.
  • Simplified error handling and logging within the function.
  • +18/-29 
    Configuration changes
    Dockerfile
    Update Golang Base Image in Dockerfile                                     

    build/Dockerfile

  • Updated the base image from golang:1.21.4-bullseye to
    golang:1.21-bullseye.
  • +1/-1     

    ✨ Usage guide:

    Overview:
    The describe tool scans the PR code changes, and generates a description for the PR - title, type, summary, walkthrough and labels. 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 describe tool (pr_description section), use the following template:

    /describe --pr_description.some_config1=... --pr_description.some_config2=...
    

    With a configuration file, use the following template:

    [pr_description]
    some_config1=...
    some_config2=...
    
    Enabling\disabling automation
    • When you first install the app, the default mode for the describe tool is:
    pr_commands = ["/describe --pr_description.add_original_user_description=true" 
                             "--pr_description.keep_original_user_title=true", ...]
    

    meaning the describe tool will run automatically on every PR, will keep the original title, and will add the original user description above the generated description.

    • Markers are an alternative way to control the generated description, to give maximal control to the user. If you set:
    pr_commands = ["/describe --pr_description.use_description_markers=true", ...]
    

    the tool will replace every marker of the form pr_agent:marker_name in the PR description with the relevant content, where marker_name is one of the following:

    • type: the PR type.
    • summary: the PR summary.
    • walkthrough: the PR walkthrough.

    Note that when markers are enabled, if the original PR description does not contain any markers, the tool will not alter the description at all.

    Custom labels

    The default labels of the describe tool are quite generic: [Bug fix, Tests, Enhancement, Documentation, Other].

    If you specify custom labels in the repo's labels page or via configuration file, you can get tailored labels for your use cases.
    Examples for custom labels:

    • Main topic:performance - pr_agent:The main topic of this PR is performance
    • New endpoint - pr_agent:A new endpoint was added in this PR
    • SQL query - pr_agent:A new SQL query was added in this PR
    • Dockerfile changes - pr_agent:The PR contains changes in the Dockerfile
    • ...

    The list above is eclectic, and aims to give an idea of different possibilities. Define custom labels that are relevant for your repo and use cases.
    Note that Labels are not mutually exclusive, so you can add multiple label categories.
    Make sure to provide proper title, and a detailed and well-phrased description for each label, so the tool will know when to suggest it.

    Inline File Walkthrough 💎

    For enhanced user experience, the describe tool can add file summaries directly to the "Files changed" tab in the PR page.
    This will enable you to quickly understand the changes in each file, while reviewing the code changes (diffs).

    To enable inline file summary, set pr_description.inline_file_summary in the configuration file, possible values are:

    • 'table': File changes walkthrough table will be displayed on the top of the "Files changed" tab, in addition to the "Conversation" tab.
    • true: A collapsable file comment with changes title and a changes summary for each file in the PR.
    • false (default): File changes walkthrough will be added only to the "Conversation" tab.
    Utilizing extra instructions

    The describe tool can be configured with extra instructions, 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. Notice that the general structure of the description is fixed, and cannot be changed. Extra instructions can change the content or style of each sub-section of the PR description.

    Examples for extra instructions:

    [pr_description] 
    extra_instructions="""
    - The PR title should be in the format: '<PR type>: <title>'
    - The title should be short and concise (up to 10 words)
    - ...
    """
    

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

    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 describe usage page for a comprehensive guide on using this tool.

    Release v0.2.9

    01 Feb 20:56
    cd2889b
    Compare
    Choose a tag to compare

    Type

    Bug fix


    Description

    • This PR fixes a failing test by updating the kubescape.io/image-tag annotation in the nginx-syft-filtered.json test data file. The image tag was changed from nginx:1.21.3 to nginx.

    Changes walkthrough

    Relevant files
    Bug fix
    nginx-syft-filtered.json
    Update image tag annotation in test data                                                 

    pkg/relevancymanager/v1/testdata/nginx-syft-filtered.json

    • Updated the value of the kubescape.io/image-tag annotation from
      nginx:1.21.3 to nginx.
    +1/-1     

    ✨ Usage guide:

    Overview:
    The describe tool scans the PR code changes, and generates a description for the PR - title, type, summary, walkthrough and labels. 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 describe tool (pr_description section), use the following template:

    /describe --pr_description.some_config1=... --pr_description.some_config2=...
    

    With a configuration file, use the following template:

    [pr_description]
    some_config1=...
    some_config2=...
    
    Enabling\disabling automation
    • When you first install the app, the default mode for the describe tool is:
    pr_commands = ["/describe --pr_description.add_original_user_description=true" 
                             "--pr_description.keep_original_user_title=true", ...]
    

    meaning the describe tool will run automatically on every PR, will keep the original title, and will add the original user description above the generated description.

    • Markers are an alternative way to control the generated description, to give maximal control to the user. If you set:
    pr_commands = ["/describe --pr_description.use_description_markers=true", ...]
    

    the tool will replace every marker of the form pr_agent:marker_name in the PR description with the relevant content, where marker_name is one of the following:

    • type: the PR type.
    • summary: the PR summary.
    • walkthrough: the PR walkthrough.

    Note that when markers are enabled, if the original PR description does not contain any markers, the tool will not alter the description at all.

    Custom labels

    The default labels of the describe tool are quite generic: [Bug fix, Tests, Enhancement, Documentation, Other].

    If you specify custom labels in the repo's labels page or via configuration file, you can get tailored labels for your use cases.
    Examples for custom labels:

    • Main topic:performance - pr_agent:The main topic of this PR is performance
    • New endpoint - pr_agent:A new endpoint was added in this PR
    • SQL query - pr_agent:A new SQL query was added in this PR
    • Dockerfile changes - pr_agent:The PR contains changes in the Dockerfile
    • ...

    The list above is eclectic, and aims to give an idea of different possibilities. Define custom labels that are relevant for your repo and use cases.
    Note that Labels are not mutually exclusive, so you can add multiple label categories.
    Make sure to provide proper title, and a detailed and well-phrased description for each label, so the tool will know when to suggest it.

    Inline File Walkthrough 💎

    For enhanced user experience, the describe tool can add file summaries directly to the "Files changed" tab in the PR page.
    This will enable you to quickly understand the changes in each file, while reviewing the code changes (diffs).

    To enable inline file summary, set pr_description.inline_file_summary in the configuration file, possible values are:

    • 'table': File changes walkthrough table will be displayed on the top of the "Files changed" tab, in addition to the "Conversation" tab.
    • true: A collapsable file comment with changes title and a changes summary for each file in the PR.
    • false (default): File changes walkthrough will be added only to the "Conversation" tab.
    Utilizing extra instructions

    The describe tool can be configured with extra instructions, 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. Notice that the general structure of the description is fixed, and cannot be changed. Extra instructions can change the content or style of each sub-section of the PR description.

    Examples for extra instructions:

    [pr_description] 
    extra_instructions="""
    - The PR title should be in the format: '<PR type>: <title>'
    - The title should be short and concise (up to 10 words)
    - ...
    """
    

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

    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 describe usage page for a comprehensive guide on using this tool.

    Release v0.1.131

    22 Dec 07:35
    6141124
    Compare
    Choose a tag to compare

    Type

    bug_fix


    Description

    This PR addresses a race condition between container start and activity reporting. The main changes include:

    • A new utility function WaitGetSafeMap has been added to safely retrieve the map for capabilities, execSets, and openSets.
    • The ReportCapability, ReportFileExec, and ReportFileOpen functions in applicationprofile_manager.go have been updated to use WaitGetSafeMap and handle any errors it returns.
    • The test in applicationprofile_manager_test.go has been updated to prepare the container before reporting capabilities, file execution, and file opening. These operations are also now run in goroutines to simulate concurrent execution.

    PR changes walkthrough

    Relevant files                                                                                                                                 
    Error handling
    1 files
    applicationprofile_manager.go                                                             
      pkg/applicationprofilemanager/v1/applicationprofile_manager.go

      The changes in this file are primarily focused on avoiding
      race conditions between container start and activity
      reporting. This is achieved by using a new utility function
      WaitGetSafeMap to safely retrieve the map for
      capabilities, execSets, and openSets. Error handling has
      been added to return early if there is an error retrieving
      the map.

    +13/-3
    Tests
    1 files
    applicationprofile_manager_test.go                                                   
      pkg/applicationprofilemanager/v1/applicationprofile_manager_test.go

      The changes in this file are related to the testing of the
      changes made in applicationprofile_manager.go. The changes
      include modifying the order of operations to prepare the
      container before reporting capabilities, file execution, and
      file opening. The operations are also now run in goroutines
      to simulate concurrent execution.

    +11/-10
    Enhancement
    1 files
    utils.go                                                                                                       
      pkg/utils/utils.go

      A new utility function WaitGetSafeMap has been added. This
      function waits for a value to be loaded into a SafeMap, with
      a timeout of 1 minute. If the value is not loaded within the
      timeout, it returns an error.

    +17/-0

    Release v0.1.130

    21 Dec 12:06
    103a4cd
    Compare
    Choose a tag to compare

    Type

    Bug fix


    Description

    This PR introduces a check to ignore eBPF events with an empty container name. This change is applied to various worker pools including capabilities, exec, open, network, and DNS worker pools. The main changes are:

    • Added a condition to return from the worker function if the container name in the event is empty.
    • Updated error messages for worker pool creation failures.

    PR changes walkthrough

    Relevant files                                                                                                                                 
    Bug fix
    1 files
    container_watcher.go                                                                               
      pkg/containerwatcher/v1/container_watcher.go

      Added checks to ignore eBPF events with an empty container
      name in capabilities, exec, open, network, and DNS worker
      pools. Also, updated the error messages for worker pool
      creation failures.
    +22/-12

    Release v0.1.129

    21 Dec 10:33
    2d895fc
    Compare
    Choose a tag to compare

    Type

    bug_fix


    Description

    This PR introduces a check to skip exec events with an empty path. This is a bug fix to prevent potential errors or unexpected behavior when an exec event with an empty path is reported. The changes include:

    • A condition to return early from the ReportFileExec function in the ApplicationProfileManager if the path is empty.
    • A corresponding test case to verify the correct behavior when an empty path is reported.

    PR changes walkthrough

    Relevant files                                                                                                                                 
    Bug fix
    1 files
    applicationprofile_manager.go                                                             
      pkg/applicationprofilemanager/v1/applicationprofile_manager.go

      Added a condition to return early from the `ReportFileExec`
      function if the path is empty.
    +4/-0
    Tests
    1 files
    applicationprofile_manager_test.go                                                   
      pkg/applicationprofilemanager/v1/applicationprofile_manager_test.go

      Added a test case to verify the correct behavior when an
      empty path is reported in the `ReportFileExec` function.
    +1/-0

    Release v0.1.128

    06 Dec 10:29
    1667a68
    Compare
    Choose a tag to compare

    Type

    Enhancement


    Description

    This PR introduces several changes:

    • The wlid annotation is added to network neighbors in the network_manager.go and network_neighbors.go files. This is done by modifying the generateNetworkNeighborsCRD function to include clusterName as a parameter and using it to generate the wlid.
    • The generateNetworkNeighborsCRD function is also updated in the network_neighbors_test.go file to reflect the changes.
    • The version of inspektor-gadget is updated from v0.23.0 to v0.23.1 in the go.mod file.

    Main files walkthrough

    files:
    • pkg/networkmanager/network_manager.go: The generateNetworkNeighborsCRD function is called with an additional clusterName parameter. This is done in two places within the handleContainerStarted and handleNetworkEvents functions.
    • pkg/networkmanager/network_neighbors.go: The generateNetworkNeighborsCRD function is updated to include clusterName as a parameter and use it to generate the wlid for the NetworkNeighbors object.
    • pkg/networkmanager/network_neighbors_test.go: The generateNetworkNeighborsCRD function is updated in the test cases to include the clusterName parameter.
    • go.mod: The version of inspektor-gadget is updated from v0.23.0 to v0.23.1. The replace directive for inspektor-gadget is removed.
    • go.sum: The checksums for the new version of inspektor-gadget are added and the old ones are removed.

    Release v0.1.127

    05 Dec 11:28
    f645867
    Compare
    Choose a tag to compare

    type:

    bug_fix, refactoring


    description:

    This PR primarily focuses on refactoring the DNS resolution process and enhancing configuration handling. The main changes include:

    • DNS resolution is no longer reliant on ebpf events. Instead, it uses the standard net.LookupIP function to resolve DNS names.
    • The CreateDNSManager function no longer requires context, config, k8sClient, storageClient, and clusterName parameters. It's now a parameterless function.
    • The CreateRelevancyManagerMock function now returns a relevancyManager object.
    • The EnableNetworkTracing configuration option has been added to the TestLoadConfig function in the config_test.go file.
    • The container collection options have been updated to use containercollection.WithContainerFanotifyEbpf instead of containercollection.WithRuncFanotify.
    • The dnsEventCallback function in container_watcher_private.go now also accepts events of type DEBUG.
    • The ApiVersionMetadataKey label has been removed from the generateNetworkNeighborsLabels function in network_neighbors.go and the corresponding tests.
    • The config.json file has been updated with fullPathTracingEnabled and networkServiceEnabled options.

    main_files_walkthrough:

    files:
    • main.go: The CreateRelevancyManagerMock function now returns a relevancyManager object. The CreateDNSManager function has been updated to not require any parameters.
    • pkg/config/config_test.go: The EnableNetworkTracing configuration option has been added to the TestLoadConfig function.
    • pkg/containerwatcher/v1/container_watcher_private.go: The container collection options have been updated to use containercollection.WithContainerFanotifyEbpf instead of containercollection.WithRuncFanotify.
    • pkg/dnsmanager/dns_manager.go: The CreateDNSManager function no longer requires context, config, k8sClient, storageClient, and clusterName parameters. It's now a parameterless function. The DNS resolution process has been updated to use the standard net.LookupIP function.
    • pkg/networkmanager/network_neighbors.go: The ApiVersionMetadataKey label has been removed from the generateNetworkNeighborsLabels function.
    • configuration/config.json: The config.json file has been updated with fullPathTracingEnabled and networkServiceEnabled options.

    Release v0.1.118

    15 Nov 10:45
    f36051a
    Compare
    Choose a tag to compare

    PR Type:

    Enhancement


    PR Description:

    This PR introduces several enhancements to the Application Profile Manager:

    • Adds support for Workload ID (WLID) to application profile objects.
    • Incorporates the cluster name into the Application Profile Manager.
    • Adds container type and index to the WatchedContainerData structure.
    • Modifies the application profile saving process to accommodate the new container type and index.
    • Updates the application profile manager tests to reflect these changes.
    • Updates the storage package version in go.mod.

    PR Main Files Walkthrough:

    files:
    • main.go: The cluster name is now passed as an argument when creating the Application Profile Manager.
    • pkg/applicationprofilemanager/v1/applicationprofile_manager.go: The Application Profile Manager structure now includes a cluster name. The CreateApplicationProfileManager function has been updated to accept the cluster name as an argument. Additional logic has been added to calculate and validate the WLID, find the container type and index, and save the application profile accordingly.
    • pkg/applicationprofilemanager/v1/applicationprofile_manager_test.go: The test for the Application Profile Manager has been updated to pass the cluster name as an argument when creating the Application Profile Manager.
    • pkg/k8sclient/k8sclient_mock.go: A new container with the name "log" and image "fluentbit" has been added to the mock workload.
    • pkg/storage/storage_mock.go: The mock Application Profile now includes a list of containers, each with its own capabilities.
    • pkg/utils/utils.go: The WatchedContainerData structure now includes a container type and index. New functions have been added to get and insert an Application Profile Container based on the container type and index.
    • go.mod: The version of the storage package has been updated from v0.0.33 to v0.0.38.

    Release v0.1.114

    01 Nov 15:06
    7458b0d
    Compare
    Choose a tag to compare

    PR Type:

    Enhancement


    PR Description:

    This PR introduces a new feature to support network neighbors. The main changes include:

    • Adding a network tracer to listen to communication.
    • Adding a network manager to handle network events.
    • Supporting services without selectors.
    • Adding tests and debug logs.
    • Fixing label selector.
    • Handling network events and generating entries for CRD.
    • Creating and updating network neighbors CRD based on events.
    • Handling services with no selectors.
    • Deleting resources when a container is removed.

    PR Main Files Walkthrough:

    files:

    pkg/networkmanager/network_manager.go: This file introduces the NetworkManager struct and its associated methods. The NetworkManager is responsible for handling network events, creating and updating network neighbors CRD based on these events, and deleting resources when a container is removed.
    pkg/containerwatcher/v1/open_test.go: This file modifies the test setup to accommodate the new NetworkManager parameter in the CreateIGContainerWatcher function.
    pkg/networkmanager/network_manager_test.go: This file includes tests for the NetworkManager, ensuring its methods function as expected.
    pkg/networkmanager/network_neighbors.go: This file introduces functions to generate network neighbors CRD and network neighbors entries.
    pkg/containerwatcher/v1/container_watcher.go: This file modifies the ContainerWatcher struct to include a NetworkManager, and updates the relevant methods to use this manager.
    pkg/networkmanager/network_event.go: This file introduces the NetworkEvent struct and its associated methods. NetworkEvent represents a network event that occurs in a container.
    pkg/storage/storage_interface.go: This file updates the StorageClient interface to include methods for creating, getting, patching, and deleting NetworkNeighbors.
    pkg/relevancymanager/v1/relevancy_manager.go: This file modifies the RelevancyManager to include a NetworkManager, and updates the relevant methods to use this manager.
    pkg/config/config.go: This file updates the Config struct to include parameters related to the NetworkManager, such as InitialDelay and UpdateDataPeriod.
    main.go: This file modifies the main function to create a NetworkManager and pass it to the RelevancyManager and ContainerWatcher.


    User Description:

    1. Add a network tracer to listen to communication.
    2. Add a network manager to handle network events

    Release v0.1.111

    25 Oct 14:47
    b3866e3
    Compare
    Choose a tag to compare

    PR Type:

    Refactoring


    PR Description:

    This pull request refactors the way the namespace is retrieved from the configuration file. Instead of hardcoding the default namespace and using an environment variable, the namespace is now passed as an argument to the CreateStorageNoCache and CreateFakeStorageNoCache functions. This change improves the flexibility and maintainability of the code.


    PR Main Files Walkthrough:

    files:

    main.go: The namespace is now passed as an argument to the CreateStorageNoCache function.
    pkg/storage/v1/storage_nocache.go: The CreateStorageNoCache and CreateFakeStorageNoCache functions now accept the namespace as an argument. The getNamespace function and the defaultNamespace constant have been removed.
    pkg/storage/v1/storage_test.go: The tests have been updated to pass the namespace as an argument to the CreateFakeStorageNoCache function. The hardcoded namespace in the tests has been replaced with a string literal "kubescape".


    User Description:

    Overview