Source Code Integration: Overview and Technical Details
Source Code Integration: Overview and Technical Details
Overview
The Source Code Inspector (SCI) a.k.a Source Code Integration is Relyance AI’s proprietary software that performs Natural Language Processing (NLP) and Static Code Analysis, a core feature of Relyance AI, to continuously detect and monitor data flows across internal microservices, machine learning (ML) pipelines, and third-parties for your privacy and data protection program.
The following topics are covered in this article:
- How to set up SCI?
- What data does SCI gather and send back to Relyance AI?
- What security controls does Relyance AI have in place?
- Common myths answered
- Integration Technical Details
Where does the SCI live?
The Source Code Inspector typically lives in a CI/CD pipeline with results being sent back to Relyance. It is suggested to create a separate CI pipeline for the Relyance scan as it is a passive scan and would impact build time. The SCI only needs access to the source code (or Code Repository).
Here is a typical high-level workflow:
How to set up SCI?
SCI runs in your environment. You can run it from a local checkout or add a dedicated scan job to your CI pipeline. Install Docker on the machine that runs the scan.
- In Relyance AI, go to Settings → Integrations → Source Code Integration. Download the
relyance.yamltemplate from Step 1 and place it at the root of your repository. Use it to set the repository name and choose the paths to scan. See the configuration details. - In Step 2, select Create a key in OAuth Credentials. Create a credential with Source Code Inspector as its only purpose. Give it a name and set its expiry.
- Copy the combined
API_KEYvalue (client_id:client_secret) before closing the dialog. The client secret is shown only once. Store the full value in your CI secret store and expose it to the scan step as theAPI_KEYenvironment variable. For a local scan, load it from your secret store into your shell environment. - Copy the Docker command from Step 2. Run it from the repository root. To use the example below, set
SCI_IMAGEto the full image reference at the end of the command in your Relyance AI instance.
docker run --pull=always --rm --env API_KEY --volume "$PWD:/repo:ro" "$SCI_IMAGE"Docker pulls the image, passes API_KEY from the environment, mounts the repository read-only at /repo, and removes the container when the scan exits. Keep the credential value in your secret store and out of commands, repository files, and logs.
If your pipeline already uses a legacy SCI key and image, you can keep that setup. Use the OAuth credential and the image shown in the OAuth setup together when you switch.
What data does SCI gather and send back to Relyance AI?
The SCI scan creates an analysis report which is sent back to Relyance AI and this only includes metadata around:
- Function and API calls
- Third-party SDK or endpoint usages
- Function formal parameters
- Call graph skeletons
Relyance AI analyzes this metadata to build a graph of any Personal Information and sensitive data in use. This graph is then used to identify data communications with third-party vendors, and internal services.
For example, SCI can determine that personal information like customer email addresses is being sent to different vendors via API calls from the source code but it never collects actual customer email addresses. Also, note that the source code is not transmitted to Relyance AI.
What security controls does Relyance AI have in place?
At Relyance AI, we provide enterprise-grade controls to ensure security at every level.
Software Protection Controls: How do we protect the SCI?
| Encryption | Integrity |
|---|---|
| The SCI binary is encrypted using AES-256-CBC encryption. During the source code scan, Relyance performs a credential exchange to decrypt the binary. Why is this important? This ensures that SCI is only run by authorized Relyance users. | A checksum is created, associated and stored within the SCI binary when it’s created. Before execution, SCI validates the checksum and only runs if it matches with the checksum set during creation. Why is this important? This ensures that SCI doesn’t execute if it's tampered during the download process from the Relyance AI server. |
Data Security & Access Controls: How do we protect data access via the SCI?
| Authentication & Authorization | Communication |
|---|---|
| SCI authenticates with the credential supplied through the scan environment. An OAuth credential for SCI must have Source Code Inspector as its only purpose. | All communications between SCI and Relyance AI is done over an encrypted channel with AES-256 encryption. Why is this important? Industry-standard encryption to ensure data is secure during transfer. |
Physical Controls: How do we protect SCI during implementation?
| Tiered approvals | Deployment controls |
|---|---|
| We follow industry-standard best practices for code review and merge. A change to SCI requires at least two levels of approvals before any SCI change is merged. Why is this important? This significantly reduces the likelihood of introducing any manual errors. | A dedicated engineer at Relyance AI is responsible to deploy SCI in production to significantly reduce the likelihood of any failures or issues. Engineers are trained on our security posture, and industry best practices every quarter. Why is this important? This significantly reduces the likelihood of introducing any manual errors. |
In addition to the controls outlined above, you can restrict outbound connections to the services listed under Prerequisites. Overall, Relyance AI has implemented a robust privacy and security program, which places maximal emphasis on the protection of customer data. Additional details about our overall security program are detailed in Relyance AI's Privacy and Security Paper.
Common myths answered
Common myths about Relyance AI’s SCI are addressed below:
- SCI does not pull source code and transmit it to Relyance AI.
- SCI doesn’t require customers to make changes in their source code unlike other Application Performance Monitoring (APM) tools in the market.
- SCI is not an SDK.
- SCI doesn’t show in your Production code, system, or logs in any way.
- Issues in the SCI will not prevent or impact any customer systems or processes. SCI can be run as a separate nightly job so it never interferes with the build process. If for any reason the SCI fails, it doesn't affect our customers’ product build, unless it’s configured as such.
- SCI is agnostic of build tools or CI/CD infrastructure.
Integration Technical Details:
i. Prerequisites
- Docker needs to be installed on the machine that runs the Relyance AI job.
- Docker needs to be configured to use Linux containers.
- Host needs to be x86_AMD64 architecture (or be able to emulate it). Tip: The latest version of Docker Desktop can emulate different architectures.
- Relyance needs to be able to communicate with GCP and Relyance. Please add the following sites to your firewall's allow-list:
- *.gcr.io
- *.relyance.ai
- *.googleapis.com
For an OAuth scan, the runner needs HTTPS access to the Relyance API for its deployment (beta.api.relyance.ai for US or beta.api.eu1.relyance.ai for EU), Google Security Token Service (sts.googleapis.com), and Cloud Storage (storage.googleapis.com). The runner also needs access to the registry in the Step 2 Docker command.
ii. Which repos should be integrated with Relyance AI?
We recommend using the following approach to identifying source code repos:
- Core backend/microservices that talk to tools and third parties (via 3rd party SDK or API calls).
- Component/services that talk to databases, data-lakes, data-warehouses, and the core backend.
- Repos that have ETL pipelines / Machine Learning DAGs to push or pull data from business applications.
The Relyance Source Code Inspector does not scan third-party directories by default. These third-party directories include:
- node_modules
- vendor
- lib/python2
- lib/python3
This is to prevent over-reporting and over-scanning. If you wish to include this folder, you'll need to explicitly specify it in the Relyance configuration file.
iii. How to update the configuration file (relyance.yaml) and what is its purpose?
The configuration file is a .yaml file. Therelyance.yaml file is used to provide build dependencies and additional information about your code repository.
The configuration file (relyance.yaml) needs to be placed in the root directory of your Github repository. You can edit the default relyance.yaml file to change it. Below is the list of configuration areas.
Configuration Area #1: Product and repository name
This configuration is used to specify the name of the product built by the repository and the name of the repository.
Example:
repository: Acme/BoutiqueAppConfiguration Area #2: Build dependency table (services, source, and product)
This configuration is used to ascertain the services impacted by the APIs. In the example configuration below, the service 'adservice' is built using the code in src/adservice and src/dbutils. Please note that the directory paths are relative to the repository's root directory.
In addition, the product field associates a set of services with a product name which can then be used as a filter in the platform. For example, in the example below, adservice and cartservice are associated with the product Boutique while checkoutservice is associated with product Boutique2.
Example:
services:
- service: adservice
product:
- Boutique
source:
- src/adservice
- src/dbutils
- service: cartservice
product:
- Boutique
source:
- src/cartservice
- service: checkoutservice
product:
- Boutique2
source:
- src/checkoutservice
- src/dbutils*Configuration Area #3:*Source directories to exclude
This configuration is used to exclude the directories you specify from Relyance AI’s SCI processing. All directory names are relative to the repository's root.
Example:
exclude:
- src/experiments
- src/adservice/playgroundConfiguration Area #4: Restricted to theseSource directories
This setting restricts the scan to only the directories you specify. Think of it like a spotlight: it will only illuminate and process what's within those specific areas, ignoring everything else. All directory names must be relative to the repository's starting point.
Example:
restrict:
- src/libraries
- src/custom_codeRelyance AI will work with your technical team to update this file.
The name of the yaml file should be “relyance. yaml”. If it does not exist, the source code inspector will search for a "relyance. yml" and failing that will check if this is a git repo to grab the repo name. If the configuration file does not exist and it is not a git repo, you will get a missing configuration file error.
Appendix:
Running the Source Code Inspector in test mode
Use dry-run mode to preview an example of the scan output locally. The container still authenticates with API_KEY. Add --command=dry_run after the image name.
docker run --pull=always --rm --env API_KEY --volume "$PWD:/repo:ro" "$SCI_IMAGE" --command=dry_runCurrently supported for all languages except Javascript/Typescript.
The output will look something like:
**************************** Relyance AI™ Inspector ****************************
* Privacy. It's in the Code™
********************************************************************************
Scanning source code...
100%|████████████████████████████████████████| 136/136 [00:01<00:00, 88.68it/s]
Elapsed: 4s
Module 'Pagerduty', version: 1, path:
'src/Pagerduty/python/EVENTS_API_v2/trigger/trigger_with_incident_key.py',
language: 'python', datetime: '2024-03-25 23:00:35', next_id: 87
Import '<built_in>'
Reference '<built_in>', kind: 'module'
Module 'python'
.....