Skip to content

Conversation

@cx-ben-alvo
Copy link
Collaborator

By submitting this pull request, you agree to the terms within the Checkmarx Code of Conduct. Please review the contributing guidelines for guidance on creating high-quality pull requests.

Description

Please provide a summary of the changes and the related issue. Include relevant motivation and context.

Type of Change

  • 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 not work as expected)
  • Documentation update

Related Issues

Link any related issues or tickets.

Checklist

  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules
  • I have updated the CLI help for new/changed functionality in this PR (if applicable)
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used

Screenshots (if applicable)

Add screenshots to help explain your changes.

Additional Notes

Add any other relevant information.

Introduced a new `oss-realtime` subcommand for performing OSS-Realtime scans efficiently. This includes a mock response for testing, a command registration, and wrapper definitions to enable easy integration and extension. The scan command outputs results in JSON format.
Replaced hardcoded mock data with dynamic file source input for building mock scan results. Added validation for the source flag and improved error handling. This ensures greater flexibility and alignment with user-specified inputs.
@github-actions
Copy link

github-actions bot commented May 7, 2025

Logo
Checkmarx One – Scan Summary & Details96be40b3-83a6-4987-87e0-f8d31f7af35c

New Issues (26)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
CRITICAL CVE-2023-41419 Python-gevent-21.8.0
detailsRecommended version: 23.9.0
Description: An issue in gevent package versions prior to 23.9.0, allows a remote attacker to escalate privileges via a crafted script to the "WSGIServer" compo...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: MPHpERiw%2BPR1iIU5qX6vTStmXIdditPiCrj5D%2Ba%2FYS0%3D
Vulnerable Package
CRITICAL CVE-2023-5457 Python-Django-3.2.25
detailsDescription: A CWE-1269 "Product Released in Non-Release Configuration" vulnerability in the Django web framework used by the web application (due to the "debug...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: ULv8LfnwsbLEdgusRiHWpK3EHCN6BA3R4%2F0e4ezLfmQ%3D
Vulnerable Package
CRITICAL CVE-2024-53908 Python-Django-3.2.25
detailsRecommended version: 4.2.17
Description: An issue was discovered in Django versions 3.1a1 through 4.2.16, 5.0a1 through 5.0.9, and 5.1a1 through 5.1.3. Direct usage of the `django.db.model...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: e6VuUeE3wq9XyB9V%2F96wIIuzxcYckb9iKv1hR5iXLXk%3D
Vulnerable Package
HIGH CVE-2021-23727 Python-celery-4.4.7
detailsRecommended version: 5.2.2
Description: This affects the package celery 4.2.1 through 5.2.1. It by default trusts the messages and metadata stored in backends (result stores). When readin...
Attack Vector: NETWORK
Attack Complexity: HIGH

ID: EAbTmwXunHRYMmbtdQjuY20GQ5IZtJkpXbu%2F9mLoG5s%3D
Vulnerable Package
HIGH CVE-2023-30861 Python-Flask-1.1.2
detailsRecommended version: 2.2.5
Description: Flask is a lightweight WSGI web application framework. When all of the following conditions are met, a response containing data intended for one cl...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: a5r6ysEQ8q0RCPbYq3NSiJCdEfzsanA231n78Zf1h40%3D
Vulnerable Package
HIGH CVE-2024-3651 Python-idna-2.10
detailsRecommended version: 3.7
Description: A vulnerability was identified in the kjd/idna library, specifically within the "idna.encode()" function. The issue arises from the function's hand...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: NSIbVPiJdGcc0pTHx%2BnGTEd8L%2FecLC%2FXIA236wUyp6I%3D
Vulnerable Package
HIGH CVE-2024-38875 Python-Django-3.2.25
detailsRecommended version: 4.2.14
Description: An issue was discovered in Django versions prior to 4.2.14, 5.0.x prior to 5.0.7, 5.1a1, and 5.1b1. "urlize" and "urlizetrunc" were subject to a po...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: LhPI1Sk%2BnsqFFaiM4maNJ5AoO88pHlk%2BPdvoy4tsvk8%3D
Vulnerable Package
HIGH CVE-2024-39330 Python-Django-3.2.25
detailsRecommended version: 4.2.14
Description: An issue was discovered in Django versions prior to 4.2.14, 5.0.x prior to 5.0.7, 5.1a1, and 5.1b1. Derived classes of the "django.core.files.stora...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: %2BcVsdIB2D1LBbLZ4Cb2YrKy2PY8obEu4VL6fR3uhs%2Bw%3D
Vulnerable Package
HIGH CVE-2024-39614 Python-Django-3.2.25
detailsRecommended version: 4.2.14
Description: An issue was discovered in Django versions prior to 4.2.14, 5.0.x prior to 5.0.7, 5.1a1, and 5.1b1. The "get_supported_language_variant()" was subj...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: BIGU8tdtxDpLbw4a3jWPWz9j48NjppQBwp%2Fb2FyQlwg%3D
Vulnerable Package
HIGH CVE-2024-41989 Python-Django-3.2.25
detailsRecommended version: 4.2.15
Description: An issue was discovered in Django versions through 4.2.14, 5.0a1 through 5.0.7, and 5.1a1 through 5.1rc1. The "floatformat" template filter is subj...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: cnQ%2Fft1VU%2F8tPeDERu9jZINwQnERuEwx0DO%2BiTVOX1Y%3D
Vulnerable Package
HIGH CVE-2024-41990 Python-Django-3.2.25
detailsRecommended version: 4.2.15
Description: An issue was discovered in Django versions through 4.2.14, 5.0a1 through 5.0.7, and 5.1a1 through 5.1rc1. The "urlize()" and "urlizetrunc()" templa...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: 0X%2FZSbWPH68wZs7gDLXnVXuAwpGn7sBc%2BZJm3XiBiPM%3D
Vulnerable Package
HIGH CVE-2024-41991 Python-Django-3.2.25
detailsRecommended version: 4.2.15
Description: An issue was discovered in Django versions through 4.2.14, 5.0a1 through 5.0.7, and 5.1a1 through 5.1rc1. The "urlize" and "urlizetrunc" template f...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: BbNVlwhm8SHk7NenkWtHxxXI7FqNmyGmNjadmry2PR0%3D
Vulnerable Package
HIGH CVE-2024-42005 Python-Django-3.2.25
detailsRecommended version: 4.2.15
Description: An issue was discovered in Django versions through 4.2.14, 5.0a1 through 5.0.7, and 5.1a1 through 5.1rc1. "QuerySet.values()" and "values_list()" m...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: lNCy8wzxZ4QScU%2FUe9qvV0sfA3cHOmKRjRT3A%2FdEaYg%3D
Vulnerable Package
HIGH CVE-2024-53907 Python-Django-3.2.25
detailsRecommended version: 4.2.17
Description: An issue was discovered in Django versions 1.6.3 through 4.2.16, 5.0a1 through 5.0.9, and 5.1a1 through 5.1.3. The `strip_tags()` method and `strip...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: Admw%2FI%2FECmFdNJ4x9c0hwDTbVRLYI1OAdBzeEdwFfMI%3D
Vulnerable Package
HIGH Cxb3ca64d2-9cd1 Npm-mocha-10.0.0
detailsRecommended version: 10.1.0
Description: The package `mocha`is vulnerable to Regular Expression Denial of Service (ReDoS). The function `clean` in `utils.js` can make the server unavailabl...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: miV2V30f5N2A6HSrXRoapmUP7mM4kH4lv1g2FQaem5k%3D
Vulnerable Package
HIGH Cxdca8e59f-8bfe Npm-inflight-1.0.6
detailsDescription: In NPM `inflight` there is a Memory Leak because some resources are not freed correctly after being used. It appears to affect all versions, as the...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: ct1%2BXm4k0NVewVlMu%2F2n3nmM2UFBpP37E4EEOUl0sT0%3D
Vulnerable Package
MEDIUM CVE-2023-0842 Npm-xml2js-0.4.23
detailsRecommended version: 0.5.0
Description: The xml2js in versions prior to 0.5.0 allows an external attacker to edit or add new properties to an object. This is possible because the applicat...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: CIwUz0XUwD4JudXpfEX8TRiLhlA8LULbr2BP8r4001c%3D
Vulnerable Package
MEDIUM CVE-2023-25399 Python-scipy-1.5.2
detailsRecommended version: 1.10.0
Description: A refcounting issue which leads to potential memory leak was discovered in scipy in "Py_FindObjects()" function prior to versions v1.10.0rc1.
Attack Vector: LOCAL
Attack Complexity: LOW

ID: M4nosXY3%2FVifrXEQVXQ71uDZm%2B31IaCWWMIKt%2BJfzng%3D
Vulnerable Package
MEDIUM CVE-2023-32681 Python-requests-2.25.1
detailsRecommended version: 2.32.0
Description: Requests is a HTTP library. Requests has been leaking Proxy-Authorization headers to destination servers when redirected to an HTTPS endpoint. This...
Attack Vector: NETWORK
Attack Complexity: HIGH

ID: ocT2qj3FjO%2BHc0znfsU99be25JvKkf9z7K85zmZ%2By6s%3D
Vulnerable Package
MEDIUM CVE-2024-11831 Npm-serialize-javascript-6.0.0
detailsRecommended version: 6.0.2
Description: A flaw was found in npm-serialize-javascript. The vulnerability occurs because the serialize-javascript module does not properly sanitize certain i...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: fE0olMD0QinHq6T71RZXQdm4RqW4nnmTwWxMEvx0gAQ%3D
Vulnerable Package
MEDIUM CVE-2024-35195 Python-requests-2.25.1
detailsRecommended version: 2.32.0
Description: Requests is an HTTP library. In the package requests versions prior to 2.32.0, when making requests through a Requests `Session`, if the first requ...
Attack Vector: LOCAL
Attack Complexity: HIGH

ID: XAH4YAEyrsRxIeR%2BB%2Fs0usCpD28M9brj3Ts0I8mhpII%3D
Vulnerable Package
MEDIUM CVE-2024-39329 Python-Django-3.2.25
detailsRecommended version: 4.2.14
Description: An issue was discovered in Django versions prior to 4.2.14, 5.0.x prior to 5.0.7, 5.1a1, and 5.1b1. The "django.contrib.auth.backends.ModelBackend....
Attack Vector: NETWORK
Attack Complexity: LOW

ID: bo4MPiFKgauv1WADU5pItVyPG7Yj3ZOOPM6uCcBmpBQ%3D
Vulnerable Package
MEDIUM CVE-2024-45231 Python-Django-3.2.25
detailsRecommended version: 4.2.16
Description: An issue was discovered in Django prior to 4.2.16, 5.0.x prior to 5.0.9, and 5.1.x prior to 5.1.1. The 'django.contrib.auth.forms.PasswordResetForm...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: OwFTrIRzFPYox%2B%2BV7TgVjYd29pR34XFAY0gHn8k4FVg%3D
Vulnerable Package
MEDIUM CVE-2024-55565 Npm-nanoid-3.3.3
detailsRecommended version: 3.3.8
Description: The package nanoid versions through 3.3.7 and 4.0.0 through 5.0.8 mishandle non-integer values.
Attack Vector: NETWORK
Attack Complexity: LOW

ID: NMEMH0d0z%2B%2F31haAjVuYDSAxagWiFBvMXj2iRV6Q7mk%3D
Vulnerable Package
MEDIUM CVE-2025-32873 Python-Django-3.2.25
detailsRecommended version: 4.2.21
Description: An issue was discovered in Django versions through 4.2.20, 5.0a1 through 5.1.8, and 5.2a1 through 5.2. The "django.utils.html.strip_tags()" functio...
Attack Vector: NETWORK
Attack Complexity: LOW

ID: 6ssk0bmVYEt%2Bs4mhCxSiMqsVbbim7Qow%2B8RUiwoFKm8%3D
Vulnerable Package
LOW Cx8bc4df28-fcf5 Npm-debug-4.3.4
detailsRecommended version: 4.4.0
Description: In NPM "debug" versions prior to 4.4.0, the "enable" function accepts a regular expression from user input without escaping it. Arbitrary regular e...
Attack Vector: NETWORK
Attack Complexity: HIGH

ID: RGJWWp8HnfIZCxT2OCqsymkyzZwZHeicJaEFL3IpjX0%3D
Vulnerable Package

Added functionality to perform OSS realtime scans, leveraging both HTTP and mock wrappers. Introduced local caching to optimize package scan results by avoiding redundant scans. Updated command dependencies and environment variable bindings to incorporate the new OSS Realtime Scanner logic.
Redefined the `ossrealtime` package to align with `commands`, and updated references accordingly. Introduced descriptive comments for `prepareScan` and `scanAndCache` functions to improve clarity. Included a new dependency (`github.com/bouk/monkey`) in `go.mod` and `go.sum`.
Introduce a `requirements.txt` file and `package.json` for dependency management, ensuring compatibility with OSS scanning. Add unit tests to verify successful and failed scans for supported and unsupported file types, improving command reliability.
…ctor OSS-Realtime scan logic and add unit tests

Renamed core functions for clarity, centralized cache key logic into the osscache package, and adjusted TTL handling. Updated CLI examples and added comprehensive tests for better scan and cache coverage.
Moved `Test_buildCacheMap` and `Test_cacheKey` to `osscache` package-specific tests to ensure proper encapsulation. Renamed associated functions to align with naming conventions (e.g., `BuildCacheMap`, `GenerateCacheKey`). Simplified `oss-realtime_test.go` by removing redundant cache-related tests.
Enhanced the sources flag to allow specifying multiple files separated by commas. Updated mock wrappers and tests to add support for caching and ensure proper handling of multiple file sources and cache usage scenarios.
Streamline the Go setup process by upgrading action versions and introducing cache cleaning and module fetching steps. Use tagged versions for actions instead of commit SHAs for readability and maintainability. Refine golangci-lint configuration to improve clarity and reliability.
Replaced deprecated and outdated linters with current alternatives, ensuring better alignment with modern practices. Adjusted linter settings, issue exclusions, and directory rules for improved linting precision and efficiency. Streamlined the configuration by removing redundant and legacy comments.
Introduced `OssRealtimeService` to encapsulate dependencies and methods related to OSSRealtime operations. Migrated functions from standalone implementations to methods of this service for improved modularity and clarity. Updated tests accordingly to use the new service structure.
@cx-ben-alvo cx-ben-alvo merged commit 6e31a8d into main May 20, 2025
12 checks passed
@cx-ben-alvo cx-ben-alvo deleted the feature/benalvo/oss-realtime branch May 20, 2025 08:13
cx-anjali-deore pushed a commit that referenced this pull request May 21, 2025
…ST-95475, AST-95476, AST-95478) (#1131)

* Add OSS-Realtime scan functionality to identify malicious packages

Introduced a new `oss-realtime` subcommand for performing OSS-Realtime scans efficiently. This includes a mock response for testing, a command registration, and wrapper definitions to enable easy integration and extension. The scan command outputs results in JSON format.

* Refactor oss-realtime to use dynamic file source flag

Replaced hardcoded mock data with dynamic file source input for building mock scan results. Added validation for the source flag and improved error handling. This ensures greater flexibility and alignment with user-specified inputs.

* Integrate OSS Realtime Scanner with caching support

Added functionality to perform OSS realtime scans, leveraging both HTTP and mock wrappers. Introduced local caching to optimize package scan results by avoiding redundant scans. Updated command dependencies and environment variable bindings to incorporate the new OSS Realtime Scanner logic.

* Add realtimeScannerWrapper to integration test setup

* Refactor OSS Realtime command structure and add comments

Redefined the `ossrealtime` package to align with `commands`, and updated references accordingly. Introduced descriptive comments for `prepareScan` and `scanAndCache` functions to improve clarity. Included a new dependency (`github.com/bouk/monkey`) in `go.mod` and `go.sum`.

* Add requirements.txt and package.json with tests for OSS scanning

Introduce a `requirements.txt` file and `package.json` for dependency management, ensuring compatibility with OSS scanning. Add unit tests to verify successful and failed scans for supported and unsupported file types, improving command reliability.

* Enhance RealtimeScannerMockWrapper to generate dynamic mock responses with random statuses

* Refactor cache file path computation into a helper function.

* Refactor OSS Realtime scan functions and enhance cache managementRefactor OSS-Realtime scan logic and add unit tests

Renamed core functions for clarity, centralized cache key logic into the osscache package, and adjusted TTL handling. Updated CLI examples and added comprehensive tests for better scan and cache coverage.

* Refactor OSS cache test logic and update function usage.

Moved `Test_buildCacheMap` and `Test_cacheKey` to `osscache` package-specific tests to ensure proper encapsulation. Renamed associated functions to align with naming conventions (e.g., `BuildCacheMap`, `GenerateCacheKey`). Simplified `oss-realtime_test.go` by removing redundant cache-related tests.

* Rename test function for OSS Realtime scan to improve clarity

* Update scanning functionality to support multiple files input

Enhanced the sources flag to allow specifying multiple files separated by commas. Updated mock wrappers and tests to add support for caching and ensure proper handling of multiple file sources and cache usage scenarios.

* Update test file paths in OSS Realtime scan tests for consistency

* Fix error message in ReadCache() test to dereference got value for clarity

* Add additional dependencies for manifest parser in golangci configuration

* Update manifest parser dependencies in golangci configuration

* Update CI configuration for Go setup and linting

Streamline the Go setup process by upgrading action versions and introducing cache cleaning and module fetching steps. Use tagged versions for actions instead of commit SHAs for readability and maintainability. Refine golangci-lint configuration to improve clarity and reliability.

* Update golangci-lint version to v2.1.6 in CI configuration

* Update golangci-lint action to a specific commit for consistency

* Update golangci-lint configuration to version 2 and refine linter settings

* Remove typecheck from golangci-lint configuration

* Refactor golangci-lint configuration by removing deprecated settings and enabling essential linters

* Enhance golangci-lint configuration with new linters and refined settings

* Add 'go mod tidy' step to CI workflow for dependency management

* Remove typecheck linter from golangci-lint configuration

* Add typecheck linter and update golangci-lint version to 1.64.2

* Add typecheck linter and update golangci-lint version to 1.64.2

* fix linter errors

* fix linter errors

* Update file path in tests to correct relative directory

Previously, the test referenced an incorrect relative path to `package.json`, causing potential failures when running tests. Updated the path to ensure it correctly points to the intended location.

* Update file path in tests to reflect new directory structure

* Update file paths in tests to match new directory structure

* Replace reflect.DeepEqual with assert.Equal in cache tests

* Update file path in tests to correct relative directory

* Update assertion in cache test to use asserts.True for TTL comparison

* Refactor OSS realtime scanning API and remove license check.

Updated the OSS scanning API to use a single structured request object instead of slices of packages. Refined HTTP wrapper logic, adjusted mock implementations, and replaced license checks with a no-op for streamlined functionality.

* Update CustomScan function to accept OssPackageRequest instead of slice

* Fix linter

* Refactor prepareScan and scanAndCache functions to use pointers for response and request types

* Add integration tests and dependencies for OSS Realtime scans

Introduced integration tests for OSS Realtime scans using `requirements.txt` and `package.json` files. Updated dependencies and modified the `scanAndCache` function to fix parameter handling in unit tests. These changes ensure better test coverage and functionality validation.

* Refactor deleteCacheFile function to remove unnecessary parameter

* Remove error logging for non-existent cache file in validation function

* Update .golangci.yml to refine linting configuration

Replaced deprecated and outdated linters with current alternatives, ensuring better alignment with modern practices. Adjusted linter settings, issue exclusions, and directory rules for improved linting precision and efficiency. Streamlined the configuration by removing redundant and legacy comments.

* Remove shadow check from golangci.yml linting configuration

* Remove revive linter from golangci.yml configuration

* Update .golangci.yml to replace maligned with revive linter

* Add nil check for JwtWrapper in ensureLicense function

* Skip test for invalid license due to unimplemented license check and update assertions for toScan package length

* Fix assertion to check length of Packages in toScan

* Refactor OSSRealtime logic into a dedicated service

Introduced `OssRealtimeService` to encapsulate dependencies and methods related to OSSRealtime operations. Migrated functions from standalone implementations to methods of this service for improved modularity and clarity. Updated tests accordingly to use the new service structure.

* Remove unused RealtimeScannerWrapperParams struct from oss-realtime.go

* Add error handling for missing file path in RunOssRealtimeScan

* Add revive rule to golangci configuration to disable stuttering check

* Add feature flag for OSS Realtime and update manifest-parser import path

* Enable OSS Realtime feature flag in test cases

* Refactor OSS Realtime scanning to use new data structures and improve error handling

* Refactor OSS Realtime service methods to remove receiver and improve readability

* Move OssPackage and OssPackageResults types to config.go for better organization

* Refactor OSS Realtime scanning to create package map after preparing scan
cx-anjali-deore pushed a commit that referenced this pull request May 21, 2025
…ST-95475, AST-95476, AST-95478) (#1131)

* Add OSS-Realtime scan functionality to identify malicious packages

Introduced a new `oss-realtime` subcommand for performing OSS-Realtime scans efficiently. This includes a mock response for testing, a command registration, and wrapper definitions to enable easy integration and extension. The scan command outputs results in JSON format.

* Refactor oss-realtime to use dynamic file source flag

Replaced hardcoded mock data with dynamic file source input for building mock scan results. Added validation for the source flag and improved error handling. This ensures greater flexibility and alignment with user-specified inputs.

* Integrate OSS Realtime Scanner with caching support

Added functionality to perform OSS realtime scans, leveraging both HTTP and mock wrappers. Introduced local caching to optimize package scan results by avoiding redundant scans. Updated command dependencies and environment variable bindings to incorporate the new OSS Realtime Scanner logic.

* Add realtimeScannerWrapper to integration test setup

* Refactor OSS Realtime command structure and add comments

Redefined the `ossrealtime` package to align with `commands`, and updated references accordingly. Introduced descriptive comments for `prepareScan` and `scanAndCache` functions to improve clarity. Included a new dependency (`github.com/bouk/monkey`) in `go.mod` and `go.sum`.

* Add requirements.txt and package.json with tests for OSS scanning

Introduce a `requirements.txt` file and `package.json` for dependency management, ensuring compatibility with OSS scanning. Add unit tests to verify successful and failed scans for supported and unsupported file types, improving command reliability.

* Enhance RealtimeScannerMockWrapper to generate dynamic mock responses with random statuses

* Refactor cache file path computation into a helper function.

* Refactor OSS Realtime scan functions and enhance cache managementRefactor OSS-Realtime scan logic and add unit tests

Renamed core functions for clarity, centralized cache key logic into the osscache package, and adjusted TTL handling. Updated CLI examples and added comprehensive tests for better scan and cache coverage.

* Refactor OSS cache test logic and update function usage.

Moved `Test_buildCacheMap` and `Test_cacheKey` to `osscache` package-specific tests to ensure proper encapsulation. Renamed associated functions to align with naming conventions (e.g., `BuildCacheMap`, `GenerateCacheKey`). Simplified `oss-realtime_test.go` by removing redundant cache-related tests.

* Rename test function for OSS Realtime scan to improve clarity

* Update scanning functionality to support multiple files input

Enhanced the sources flag to allow specifying multiple files separated by commas. Updated mock wrappers and tests to add support for caching and ensure proper handling of multiple file sources and cache usage scenarios.

* Update test file paths in OSS Realtime scan tests for consistency

* Fix error message in ReadCache() test to dereference got value for clarity

* Add additional dependencies for manifest parser in golangci configuration

* Update manifest parser dependencies in golangci configuration

* Update CI configuration for Go setup and linting

Streamline the Go setup process by upgrading action versions and introducing cache cleaning and module fetching steps. Use tagged versions for actions instead of commit SHAs for readability and maintainability. Refine golangci-lint configuration to improve clarity and reliability.

* Update golangci-lint version to v2.1.6 in CI configuration

* Update golangci-lint action to a specific commit for consistency

* Update golangci-lint configuration to version 2 and refine linter settings

* Remove typecheck from golangci-lint configuration

* Refactor golangci-lint configuration by removing deprecated settings and enabling essential linters

* Enhance golangci-lint configuration with new linters and refined settings

* Add 'go mod tidy' step to CI workflow for dependency management

* Remove typecheck linter from golangci-lint configuration

* Add typecheck linter and update golangci-lint version to 1.64.2

* Add typecheck linter and update golangci-lint version to 1.64.2

* fix linter errors

* fix linter errors

* Update file path in tests to correct relative directory

Previously, the test referenced an incorrect relative path to `package.json`, causing potential failures when running tests. Updated the path to ensure it correctly points to the intended location.

* Update file path in tests to reflect new directory structure

* Update file paths in tests to match new directory structure

* Replace reflect.DeepEqual with assert.Equal in cache tests

* Update file path in tests to correct relative directory

* Update assertion in cache test to use asserts.True for TTL comparison

* Refactor OSS realtime scanning API and remove license check.

Updated the OSS scanning API to use a single structured request object instead of slices of packages. Refined HTTP wrapper logic, adjusted mock implementations, and replaced license checks with a no-op for streamlined functionality.

* Update CustomScan function to accept OssPackageRequest instead of slice

* Fix linter

* Refactor prepareScan and scanAndCache functions to use pointers for response and request types

* Add integration tests and dependencies for OSS Realtime scans

Introduced integration tests for OSS Realtime scans using `requirements.txt` and `package.json` files. Updated dependencies and modified the `scanAndCache` function to fix parameter handling in unit tests. These changes ensure better test coverage and functionality validation.

* Refactor deleteCacheFile function to remove unnecessary parameter

* Remove error logging for non-existent cache file in validation function

* Update .golangci.yml to refine linting configuration

Replaced deprecated and outdated linters with current alternatives, ensuring better alignment with modern practices. Adjusted linter settings, issue exclusions, and directory rules for improved linting precision and efficiency. Streamlined the configuration by removing redundant and legacy comments.

* Remove shadow check from golangci.yml linting configuration

* Remove revive linter from golangci.yml configuration

* Update .golangci.yml to replace maligned with revive linter

* Add nil check for JwtWrapper in ensureLicense function

* Skip test for invalid license due to unimplemented license check and update assertions for toScan package length

* Fix assertion to check length of Packages in toScan

* Refactor OSSRealtime logic into a dedicated service

Introduced `OssRealtimeService` to encapsulate dependencies and methods related to OSSRealtime operations. Migrated functions from standalone implementations to methods of this service for improved modularity and clarity. Updated tests accordingly to use the new service structure.

* Remove unused RealtimeScannerWrapperParams struct from oss-realtime.go

* Add error handling for missing file path in RunOssRealtimeScan

* Add revive rule to golangci configuration to disable stuttering check

* Add feature flag for OSS Realtime and update manifest-parser import path

* Enable OSS Realtime feature flag in test cases

* Refactor OSS Realtime scanning to use new data structures and improve error handling

* Refactor OSS Realtime service methods to remove receiver and improve readability

* Move OssPackage and OssPackageResults types to config.go for better organization

* Refactor OSS Realtime scanning to create package map after preparing scan
cx-anjali-deore pushed a commit that referenced this pull request Jul 3, 2025
…ST-95475, AST-95476, AST-95478) (#1131)

* Add OSS-Realtime scan functionality to identify malicious packages

Introduced a new `oss-realtime` subcommand for performing OSS-Realtime scans efficiently. This includes a mock response for testing, a command registration, and wrapper definitions to enable easy integration and extension. The scan command outputs results in JSON format.

* Refactor oss-realtime to use dynamic file source flag

Replaced hardcoded mock data with dynamic file source input for building mock scan results. Added validation for the source flag and improved error handling. This ensures greater flexibility and alignment with user-specified inputs.

* Integrate OSS Realtime Scanner with caching support

Added functionality to perform OSS realtime scans, leveraging both HTTP and mock wrappers. Introduced local caching to optimize package scan results by avoiding redundant scans. Updated command dependencies and environment variable bindings to incorporate the new OSS Realtime Scanner logic.

* Add realtimeScannerWrapper to integration test setup

* Refactor OSS Realtime command structure and add comments

Redefined the `ossrealtime` package to align with `commands`, and updated references accordingly. Introduced descriptive comments for `prepareScan` and `scanAndCache` functions to improve clarity. Included a new dependency (`github.com/bouk/monkey`) in `go.mod` and `go.sum`.

* Add requirements.txt and package.json with tests for OSS scanning

Introduce a `requirements.txt` file and `package.json` for dependency management, ensuring compatibility with OSS scanning. Add unit tests to verify successful and failed scans for supported and unsupported file types, improving command reliability.

* Enhance RealtimeScannerMockWrapper to generate dynamic mock responses with random statuses

* Refactor cache file path computation into a helper function.

* Refactor OSS Realtime scan functions and enhance cache managementRefactor OSS-Realtime scan logic and add unit tests

Renamed core functions for clarity, centralized cache key logic into the osscache package, and adjusted TTL handling. Updated CLI examples and added comprehensive tests for better scan and cache coverage.

* Refactor OSS cache test logic and update function usage.

Moved `Test_buildCacheMap` and `Test_cacheKey` to `osscache` package-specific tests to ensure proper encapsulation. Renamed associated functions to align with naming conventions (e.g., `BuildCacheMap`, `GenerateCacheKey`). Simplified `oss-realtime_test.go` by removing redundant cache-related tests.

* Rename test function for OSS Realtime scan to improve clarity

* Update scanning functionality to support multiple files input

Enhanced the sources flag to allow specifying multiple files separated by commas. Updated mock wrappers and tests to add support for caching and ensure proper handling of multiple file sources and cache usage scenarios.

* Update test file paths in OSS Realtime scan tests for consistency

* Fix error message in ReadCache() test to dereference got value for clarity

* Add additional dependencies for manifest parser in golangci configuration

* Update manifest parser dependencies in golangci configuration

* Update CI configuration for Go setup and linting

Streamline the Go setup process by upgrading action versions and introducing cache cleaning and module fetching steps. Use tagged versions for actions instead of commit SHAs for readability and maintainability. Refine golangci-lint configuration to improve clarity and reliability.

* Update golangci-lint version to v2.1.6 in CI configuration

* Update golangci-lint action to a specific commit for consistency

* Update golangci-lint configuration to version 2 and refine linter settings

* Remove typecheck from golangci-lint configuration

* Refactor golangci-lint configuration by removing deprecated settings and enabling essential linters

* Enhance golangci-lint configuration with new linters and refined settings

* Add 'go mod tidy' step to CI workflow for dependency management

* Remove typecheck linter from golangci-lint configuration

* Add typecheck linter and update golangci-lint version to 1.64.2

* Add typecheck linter and update golangci-lint version to 1.64.2

* fix linter errors

* fix linter errors

* Update file path in tests to correct relative directory

Previously, the test referenced an incorrect relative path to `package.json`, causing potential failures when running tests. Updated the path to ensure it correctly points to the intended location.

* Update file path in tests to reflect new directory structure

* Update file paths in tests to match new directory structure

* Replace reflect.DeepEqual with assert.Equal in cache tests

* Update file path in tests to correct relative directory

* Update assertion in cache test to use asserts.True for TTL comparison

* Refactor OSS realtime scanning API and remove license check.

Updated the OSS scanning API to use a single structured request object instead of slices of packages. Refined HTTP wrapper logic, adjusted mock implementations, and replaced license checks with a no-op for streamlined functionality.

* Update CustomScan function to accept OssPackageRequest instead of slice

* Fix linter

* Refactor prepareScan and scanAndCache functions to use pointers for response and request types

* Add integration tests and dependencies for OSS Realtime scans

Introduced integration tests for OSS Realtime scans using `requirements.txt` and `package.json` files. Updated dependencies and modified the `scanAndCache` function to fix parameter handling in unit tests. These changes ensure better test coverage and functionality validation.

* Refactor deleteCacheFile function to remove unnecessary parameter

* Remove error logging for non-existent cache file in validation function

* Update .golangci.yml to refine linting configuration

Replaced deprecated and outdated linters with current alternatives, ensuring better alignment with modern practices. Adjusted linter settings, issue exclusions, and directory rules for improved linting precision and efficiency. Streamlined the configuration by removing redundant and legacy comments.

* Remove shadow check from golangci.yml linting configuration

* Remove revive linter from golangci.yml configuration

* Update .golangci.yml to replace maligned with revive linter

* Add nil check for JwtWrapper in ensureLicense function

* Skip test for invalid license due to unimplemented license check and update assertions for toScan package length

* Fix assertion to check length of Packages in toScan

* Refactor OSSRealtime logic into a dedicated service

Introduced `OssRealtimeService` to encapsulate dependencies and methods related to OSSRealtime operations. Migrated functions from standalone implementations to methods of this service for improved modularity and clarity. Updated tests accordingly to use the new service structure.

* Remove unused RealtimeScannerWrapperParams struct from oss-realtime.go

* Add error handling for missing file path in RunOssRealtimeScan

* Add revive rule to golangci configuration to disable stuttering check

* Add feature flag for OSS Realtime and update manifest-parser import path

* Enable OSS Realtime feature flag in test cases

* Refactor OSS Realtime scanning to use new data structures and improve error handling

* Refactor OSS Realtime service methods to remove receiver and improve readability

* Move OssPackage and OssPackageResults types to config.go for better organization

* Refactor OSS Realtime scanning to create package map after preparing scan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants