Archived Java/Spring OSA Proxy implementation
This page describes the archived Java/Spring implementation of OSA Proxy. For new installations, use the current implementation: OSA Proxy.
Overview
OSA Proxy (repo-manager-proxy) is a proxy service that acts as an intermediary between package managers and their remote repositories. It integrates with the CodeScoring platform and provides automatic scanning of downloaded components and blocking of unsafe packages according to security policies.
The service intercepts requests made by package managers, sends them to the source repositories, analyzes the received packages, modifies the responses, and manages access to components.
The service is based on an asynchronous processing model and an automatic retry mechanism for temporary errors.
Supported package managers
OSA Proxy handles requests to the following repositories:
- Maven Central (
https://repo1.maven.org/maven2) - NPM Registry (
https://registry.npmjs.org) - PyPI (
https://pypi.org) - NuGet V3 (
https://api.nuget.org) - Go (
https://proxy.golang.org/) - Debian (
https://ports.ubuntu.com/ubuntu-ports) - Alpine/APK (
https://dl-cdn.alpinelinux.org/alpine) - RPM (
https://repo.almalinux.org/almalinux) - Docker Registry (
https://registry-1.docker.io)
The service also supports alternative repositories that implement the official specifications of the corresponding package manager (for example, Nexus Repository and JFrog Artifactory).
Main functionality
Package scanning
Two scanning levels are implemented for each ecosystem:
- Manifest scanning — analyzes and excludes versions blocked by security policies from the manifest
- Package scanning — analyzes downloaded package
Blocking insecure components
If a component violates security policy rules:
- Insecure versions are excluded from the list of available versions in the manifest;
- Downloading of corresponding archives is blocked;
- A configurable status code is returned with a message explaining the reason for the blocking.
Response modification
OSA Proxy automatically modifies responses from original repositories:
- Redirects all URLs;
- Removes blocked versions from metadata;
- Recalculates checksums of modified manifests to maintain the correct format.
Policy results caching
To speed up request processing and reduce platform load, policy validation results (verdicts from Judge service) are cached in Redis. Background updates of outdated records are supported.
Work modes
Package scanning behavior is controlled by the work-mode parameter. Depending on the selected value, the scanning, waiting, and blocking logic changes. The following modes are supported:
warmup– loads data into the CodeScoring cache without blocking components;spectator– loads data into the CodeScoring cache without blocking components, saving the results of component queries to the platform;moderate– blocks components that fail policy checks. Loading unscanned components is allowed;strict– blocks components that fail policy checks. Loading unscanned components is prohibited;strict_wait– blocks components that fail policy checks. Waiting for checks for unscanned components.
Deployment
Following the configuration of the application.yml file, the application can be deployed and executed either within a Docker container environment or orchestrated via a Helm chart for Kubernetes (k8s) deployments.
Docker container deployment
To instantiate the application as a Docker container, execute the following command:
Kubernetes deployment (Helm Chart)
For Kubernetes environments, the application can be deployed using the provided Helm chart, accessible at https://{REGISTRY_URL}/repository/helm/.
Installation order:
-
Create a namespace.
-
Create a secret to access the private Docker registry, using the address (
REGISTRY_URL), login (USERNAME) and password (PASSWORD) received from the vendor. -
Install Helm using your preferred method.
-
Run the following commands to add the current Helm repository to the local machine:
-
Create a
values.yamlfile with the following content: -
Run the command to install the chart
Service configuration
Main parameters
Configuration of OSA Proxy is done via the application.yml file:
- For JFrog Artifactory, it is recommended to set a
Custom Base URLand use it in theregistryfield to correctly replace package references within manifests. - In the configuration
package manager->jfrog->OSA proxy->internet, in the additional JFrog repository settings, it is necessary to set theBypass HEAD requests flag. - There is no identical functionality for Nexus Repository; the host and port (if specified) from the request will be used in manifests. If a
reverse proxyis available, it is recommended to use its link. For example:registry: https://nexushost.ru/repository/pypi-proxy.
Additional settings
Logging level settings
Viewing blocked packages in logs
To find blocked packages in the application logs, ensure the logging level for ru.codescoring is set to info or lower. The PolicyLogger component will output information about blocked packages in the following formats:
- For packages blocked by policies:
Policy '<policy_name>' blocked package '<package_name>' versions: [<versions>] - For OSA packages blocked by the platform:
Policy blocked package '<purl>' for endpoint '<endpoint>': <reason>
Logging external requests
External requests to third-party registries can be logged using the ru.codescoring.proxy.logging.RegistryRequestResponseLogger component. To do this, set its logging level to trace.
Blocked version handling mode in manifests
The codescoring.remove-blocked-versions parameter controls how blocked package versions are displayed in npm, PyPI, and NuGet manifests:
true(default) — blocked versions are fully removed from the manifest. The package manager does not see them and will not offer them to the user.false— blocked versions remain in the manifest but are marked as deprecated, with the name of the triggered policy included in the relevant field:- npm — the
deprecatedfield of the version entry contains the policy name; - PyPI — the
data-yankedattribute of the package link contains the policy name; - NuGet — the
deprecation.messagefield of the entry contains the policy name, andlistedis set tofalse.
- npm — the
Buffer size for large manifests
Retry policies and circuit breaker for platform requests
Retry configuration
This configuration defines the retry policy for the codeScoringApi service. It is designed to handle temporary failures by retrying up to 3 times.
Retries use an exponential backoff strategy, starting with a 1-second delay and doubling it with each attempt. This policy applies only to certain exceptions, such as WebClientRequestException.
Circuit breaker configuration
The circuit breaker for codeScoringApi acts as a fail-fast mechanism. It tracks failure rates, and if they reach 50% (calculated over the last 20 calls), it “opens” and prevents further requests for 30 seconds. This gives the downstream service time to recover. After the wait period, it switches to “half-open” state, allowing 5 trial calls to check if the service has recovered.
Retry and circuit breaker configuration can be overridden by setting the following properties, for example, for codeScoringApi.
Adding truststore certificates
Adding http proxy
Redis and сaching сonfiguration
To improve performance and reduce load on the CodeScoring platform, caching of policy checking results (Judge service) is supported. Caching requires a Redis connection.
Proactive refresh does not prolong the TTL (time-to-live) of a cache entry. The TTL is only extended when data is read from the cache by actual user requests. This ensures that only frequently requested components remain in the cache, while rarely used ones are automatically removed from Redis.
Swagger UI
OSA Proxy provides Swagger UI for API documentation and cache management.
- URL:
http://<osa-proxy-host>:<port>/api/swagger - Available operations:
- Clear cache by PURL
- Clear cache by package type
Supported protocols
This section contains data formats and response modification rules for each supported package manager in OSA Proxy.
Maven
Processed files
maven-metadata.xml- version information manifest.jar,.war,.ear- package files
maven-metadata.xml field modifications
NPM
Files processed
- Package JSON manifest (path
/{repository}/*) .tgz- package archives
NPM Manifest field modifications
PyPI
Files and resources
- Simple API HTML pages (path
/{repository}/simple/*) .zip,.tar,.tgz,.tar.gz,.tar.bz2,.egg,.whl- package files
HTML page modifications
- Elements for blocked versions are removed
- URLs are rewritten for proxy downloading
NuGet
Handled resources
index.json- service index- Registration index JSON
.nupkg- package files
Registration index modifications
Go
Processed files
- Version list (
/@v/list) .zip— module archives
Version list modifications
- Blocked versions are removed from the version list
Debian
Processed files
.deb— package files
For Debian, only package scanning is supported. Modification of manifests (Packages files) is not performed.
Alpine
Processed files
.apk— package files
For Alpine, only package scanning is supported. Modification of indexes (APKINDEX) is not performed.
RPM
Processed files
.rpm— package files
For RPM, only package scanning is supported. Modification of metadata (repodata) is not performed.
Docker
Processed files
- Manifests (v2 API)
Manifest modification
- Digests of blocked images are removed from multi-architecture manifests (Manifest Lists).
Behavior in case of complete package blocking
In a scenario where all available versions of a requested package are blocked by security policies, OSA Proxy returns a message indicating that all versions are blocked.
Since some package manager clients might not display this specific blocking message in the user interface, it is recommended to use the curl utility for direct diagnosis of the package status. Below are examples of curl requests to check the blocking status for various package types:
Pip
Maven
npm
NuGet
Although the NuGet client might display the reason for blocking all packages in the console, a direct curl request also allows for status confirmation:
Go
Metric collection
Metrics are available in OSA Proxy at {osa-proxy-url}/actuator/metrics in JSON format, as well as in the Prometheus format {platform-url}/actuator/prometheus.
These metrics are collected for each repository type (maven, pypi, nuget, npm) and allow detailed monitoring of incoming requests to proxy repositories.
Available metrics
gateway_route_<package-type>_requests_seconds_count– total number of requests processed;gateway_route_<package-type>_requests_seconds_sum– total request processing time, used to calculate average response time;gateway_route_<package-type>_requests_seconds_max– maximum request processing time;gateway_route_<package-type>_requests_seconds_bucket– SLO (Service Level Objective) response time metrics with buckets: 10ms, 25ms, 50ms, 100ms, 250ms, 500ms, 1s, 2s, 5s.
When collecting metrics, <package-type> is replaced with the corresponding repository type: maven, pypi, nuget, npm, go, debian, alpine, rpm, docker. For example, for a Maven repository, the metric will be called gateway_route_maven_requests_total.
These metrics can be filtered by the following labels:
operation– the type of operation performed on the package;scan_package– package scanning;scan_manifest– manifest scanning;other– other operations (e.g., transferring files not subject to analysis).
method– HTTP request method (GET,POST,PUT, etc.);repository– the name of the repository to which the request was made;status– HTTP response status code (e.g.,200,403,500);outcome– request processing result;success– request successfully processed;error– an error occurred during processing (status 400 or higher, excluding the blocking code);blocked_by_policies– the request was blocked by security policies.
CodeScoring API Metrics
To monitor interaction with the CodeScoring platform, the following metrics are available:
codescoring_api_requests_seconds_count– total number of requests to the CodeScoring API;codescoring_api_requests_seconds_sum– total execution time of requests to the API;codescoring_api_requests_seconds_max– maximum execution time of a request to the API;codescoring_api_requests_seconds_bucket– SLO metrics for API response time with buckets: 10ms, 25ms, 50ms, 100ms, 250ms, 500ms, 1s, 2s, 5s.
These metrics allow tracking:
- Performance of interaction with the CodeScoring platform
- Number of component scan requests
- API response time to identify connection issues
- Load on the platform from OSA Proxy
Base64 URL Parameters
Using Base64 URL Parameters for osa-proxy
In certain scenarios, interacting with osa-proxy requires explicitly specifying additional parameters in the URL path. This is achieved by encoding the required information in Base64 (URL-safe) format.
The primary purpose of using Base64-encoded parameters is to provide osa-proxy with the necessary context to correctly apply security policies, especially when osa-proxy acts as an intermediary for external repositories.
Automatic Context Detection
When osa-proxy is placed between a client (package manager) and an internal repository manager (e.g., JFrog Artifactory or Nexus Repository Manager), osa-proxy can automatically extract the host and repository name from the downstream repository settings.
Example configuration where context is automatically determined:
Explicit Context Specification via Base64 Parameters
In cases where osa-proxy directly interacts with external, public repositories (e.g., https://registry.npmjs.org), it cannot independently retrieve information about the internal host and repository name. In this situation, it is critical for osa-proxy to receive this data to apply linked security policies and process the request correctly.
For this purpose, a Base64-encoded string is used, which contains a JSON object with parameters such as repoManagerHost and repoName. This string is embedded directly into the request URL, allowing osa-proxy to obtain the necessary context.
Example configuration requiring explicit context specification:
How it works:
The Base64-encoded parameter string is placed in the URL path immediately after the repository name. osa-proxy decodes this string, extracts the parameters, and uses them to perform its functions, including applying security policies associated with a specific internal repository.
General URL Structure:
https://<osaproxy-host>/<repository-name>/<base64-parameters>/<rest-of-path>
Passing Context for Correct Operation of Security Policies Linked to Nexus and Artifactory Repositories
Developer Client -> Nexus / Artifactory -> osa-proxy -> Internet
To pass contextual information, including the host and repository name of your repository manager, this data should be integrated into a Base64-encoded parameter string. It is important to strictly adhere to the rule that this Base64 string must be placed immediately after the repository name in the URL.
Configuration Update
It is necessary to mark the repository as compatible with Base64 parameters using url-encoded-config: true.
Nexus
- Go to Server Administration -> Repositories.
- Select the desired type (e.g.,
maven2 (proxy)). - In the Remote storage field, enter the URL of your
osa-proxyinstance, including the repository name and Base64-encoded parameters.
Example for a Maven proxy repository:
https://osaproxy.example.com/internet-maven/eyJyZXBvTWFuYWdlckhvc3QiOiJodHRwczovL3JlcG8xLm1hdmVuLm9yZy9tYXZlbjIiLCJyZXBvTmFtZSI6ImludGVybmV0LW1hdmVuIn0/maven2
Artifactory
- Go to Administration -> Repositories -> Remote.
- In the configuration, set the URL field to the
osa-proxyURL. This URL must include the repository name and the Base64-encoded string.
Example for a remote PyPI repository:
https://osaproxy.example.com/internet-pypi/eyJyZXBvTWFuYWdlckhvc3QiOiJodHRwczovL3B5cGkub3JnL3NpbXBsZSIsInJlcG9OYW1lIjoiaW50ZXJuZXQtcHlwaSJ9/simple
Rule
The Base64-encoded parameter string must be placed in the URL path immediately after the repository name.
The general URL structure is as follows:
https://<osaproxy-host>/<repository-name>/<base64-parameters>/<rest-of-path>
Where:
<osaproxy-host>: The hostname of theosa-proxyinstance.<repository-name>: The name of the repository being accessed.<base64-parameters>: A URL-safe Base64-encoded JSON string containing the parameters.<rest-of-path>: The remaining part of the path from the package manager settings.
Example
For example, to pass the following parameters as a JSON object:
To do this, you should:
- Convert the JSON object to a string.
- Encode the string using URL-safe Base64.
The result of encoding the above JSON object in Base64:
eyJyZXBvTWFuYWdlckhvc3QiOiJodHRwczovL25leHVzLnRlc3QucnUiLCJyZXBvTmFtZSI6Im5wbS1wcm94eSJ9
Configuring Package Managers
To permanently use the URL with Base64 parameters for all requests, update your package manager's configuration file.
NPM
For NPM, edit .npmrc file and set the registry key.
The URL should include the repository name and the Base64 encoded string.
Maven
For Maven, edit settings.xml file. You can add a new <mirror> in the <mirrors> section.
The <url> tag should contain the full URL, including the repository name and the Base64 encoded string.
Make sure the <mirrorOf> value matches the repositories you want to proxy.
Go
For Go, set the GOPROXY environment variable to include the repository name and the Base64-encoded string.
Debian
For Debian, edit /etc/apt/sources.list or a file in /etc/apt/sources.list.d/. Update the URIs field.
NuGet
For NuGet, edit NuGet.config file and add a new package source. The value attribute of the <add> tag should contain the full URL.
PyPI
For PyPI, edit pip.conf (Linux/macOS) or pip.ini (Windows) file and set the index-url.
Maven сonfiguration
Repository URL migration
Use case: migrating a Maven repository from Artifactory to OSA Proxy.
The following table provides a summary of repository URL redirection for Maven. Authentication parameters and other configurations, such as username and password, remain unchanged.
Maven registry migration
Original .m2/settings.xml file:
The following repository definition needs to be added to the service's YAML configuration (the application.yml file) under the maven section. A service restart is required to apply the changes.
Configuration in application.yml file
Updated .m2/settings.xml file:
NPM Configuration
Repository URL migration
Use Case: Migrating an npm repository from Artifactory to OSA Proxy.
The following table provides a summary of repository URL redirection for NPM. Authentication parameters and other configurations, such as username and password, remain unchanged.
NPM registry migration
Original .npmrc file:
The following repository definition needs to be added to the service's YAML configuration (the application.yml file) under the npm section. A service restart is required to apply the changes.
Configuration in application.yml file
Updated .npmrc file:
NuGet Configuration
Repository URL migration
Use case: migrating a NuGet repository from Artifactory to OSA Proxy.
The following table provides a summary of repository URL redirection for NuGet. Authentication parameters and other configurations, such as username and password, remain unchanged.
NuGet registry migration
Original NuGet.config file:
The following repository definition needs to be added to the service's YAML configuration (the application.yml file) under the nuget section. A service restart is required to apply the changes.
Configuration in application.yml file
Updated NuGet.config file:
PyPI Configuration
Repository URL migration
Use case: migrating a PyPI repository from Artifactory to OSA Proxy.
The following table provides a summary of repository URL redirection for PyPI. Authentication parameters and other configurations, such as username and password, remain unchanged.
PyPI registry migration
Original pip.conf (Linux/macOS) or pip.ini (Windows) file:
Or with authentication:
The following repository definition needs to be added to the service's YAML configuration (the application.yml file) under the pypi section. A service restart is required to apply the changes.
Configuration in application.yml file
GitLab configuration example in application.yml:
Updated pip.conf (Linux/macOS) or pip.ini (Windows) file:
Or with authentication:
Multiple package registries
Some PyPI repositories may serve packages from multiple hosts. For example, the download.pytorch.org index contains links to both its own CDN hosts and the standard files.pythonhosted.org.
To correctly proxy such repositories, use the additional-packages-registries parameter — a map where the key specifies the source host and the value specifies the package registry URL to route requests to.
PyTorch configuration example:
Configuration file locations
- Linux/macOS:
~/.config/pip/pip.confor~/.pip/pip.conf - Windows:
%APPDATA%\pip\pip.inior%HOME%\pip\pip.ini - Per-virtualenv:
$VIRTUAL_ENV/pip.conf
Go Configuration
Go Proxy Migration
Use case: Migrating Go to use an OSA Proxy instead of direct access or external public proxies.
The following table summarizes URL redirection for the Go proxy. Authentication parameters and other settings (if applicable, e.g., for private repositories requiring specific credentials) should be configured separately in accordance with your corporate policies (e.g., via .netrc or SSH keys).
The Checksum DB is not a separate GOPROXY endpoint. It is configured via the GOSUMDB environment variable. See the section below for details.
Go Proxy Migration Details
Environment Configuration Before Migration
Before migration, your GOPROXY might have been set to the public Go proxy (https://proxy.golang.org) or not set at all, which would default to using proxy.golang.org.
The following repository definition needs to be added to the service's YAML configuration (the application.yml file) in the go section. A service restart is required for the changes to take effect.
Configuration in application.yml file
Example of current environment variable configuration (e.g., in .bashrc, .zshrc file, or in a CI/CD pipeline):
Checksum Database Configuration
To proxy requests to sum.golang.org through OSA Proxy, use the GOSUMDB environment variable. Its value follows the format <db-name> <proxy-url>, where the URL is constructed as {osa-proxy-url}/{repo-name}/sumdb/sum.golang.org:
Full usage example:
Debian Package Configuration
Repository URL Migration
Use case: Migration of Debian repositories from direct sources to an OSA Proxy server.
The following table summarizes the redirection of repository URLs for Debian. Please note that the format of the deb or deb-src repository lines (distribution, components) remains unchanged; only the base repository URL changes.
APT Repository Migration
Original file /etc/apt/sources.list or /etc/apt/sources.list.d/*.list:
The following repository definition needs to be added to the service's YAML configuration (the application.yml file) in the debian section. The service must be restarted for the changes to take effect.
Configuration in application.yml file
After configuring the proxy server and adding it to application.yml, your sources.list will look like this:
Docker Registry Configuration
Registry URL Migration
Use case: Migration of Docker registries from direct sources to an OSA Proxy server.
The following table summarizes the redirection of URLs for Docker.
Docker Client Migration
The following repository definition needs to be added to the service's YAML configuration (the application.yml file) in the docker section. The service must be restarted for the changes to take effect.
Configuration in application.yml file
After configuring the proxy server and adding it to application.yml, the command to pull an image will look like this:
Using subdomains for access
If you want to use more than one Docker repository, you need to enable subdomains. The subdomain names must match the repository names specified in the docker.repository configuration.
In this case, the command to pull an image will look like this:
For a single repository, there is no need to add a subdomain — Docker will be available directly via the OSA Proxy host:
Alpine Package Configuration
Repository URL Migration
Use case: Migration of Alpine repositories from direct sources to an OSA Proxy server.
The following table summarizes the redirection of repository URLs for Alpine.
APK Repository Migration
Original file /etc/apk/repositories:
The following repository definition needs to be added to the service's YAML configuration (the application.yml file) in the alpine section. The service must be restarted for the changes to take effect.
Configuration in application.yml file
After configuring the proxy server and adding it to application.yml, your repositories file will look like this:
RPM Package Configuration
Repository URL Migration
Use case: Migration of RPM repositories (YUM/DNF) from direct sources to an OSA Proxy server.
The following table summarizes the redirection of repository URLs for RPM.
YUM/DNF Repository Migration
Original file /etc/yum.repos.d/almalinux.repo:
The following repository definition needs to be added to the service's YAML configuration (the application.yml file) in the rpm section. The service must be restarted for the changes to take effect.
Configuration in application.yml file
After configuring the proxy server and adding it to application.yml, the repository configuration will look like this:
