This topic describes the advanced code search feature in Apsara Devops. This feature lets you search for code snippets, repositories, commits, and merge requests. You can use it to find API call relationships, package dependencies, and the usage of sensitive information across your organization's repositories.
This feature is available only in the Premium Edition. For more information, see Version Guide.
Scenarios
The advanced code search service in Apsara Devops helps developers solve various coding problems, such as finding code snippets, identifying dependencies, and troubleshooting security risks. The following sections describe common scenarios and their corresponding solutions.
Scenario 1: Find a code snippet
Problem
A developer wants to reference a code snippet but cannot remember where they saw it.
Solution
Search for keywords: On the Apsara Devops platform, use the advanced code search feature. Enter keywords such as a function name, class name, or a specific code snippet.
Filter results: Narrow the search by repository, file type, file path, or programming language.
View results: Review the search results to find the code snippet. View the code in context to understand its implementation.
Scenario 2: Identify code dependencies
Problem
A developer is changing a configuration parameter or a function variable and is not sure whether other repositories in the organization depend on it.
Solution
Search for dependencies: Use the advanced code search feature to search for the name of the parameter or variable that you want to change.
Locate references: Review the search results to find all references to the parameter or variable.
Assess the impact: Use the search results to assess the impact of the change. This ensures that the change does not cause issues in other modules.
Scenario 3: Troubleshoot security risks
Problem
A security administrator is concerned about the risk of exposing private database passwords or tokens in plaintext.
Solution
Search for sensitive information: Use the advanced code search feature to search for keywords related to sensitive information, such as database passwords or tokens.
Locate sensitive information: Review the search results to find all code that contains sensitive information.
Investigate and remediate: Examine each search result to check for plaintext exposure risks.
Advanced code search
Log on to Apsara Devops Codeup. Click the search box in the top navigation bar to open the global search window. Enter your code keywords. In the search results, click Go to Advanced Code Search to open the advanced code search page:
If you are using this feature for the first time, follow the prompts on the page to enable it. After the feature is enabled, your code is indexed. Wait 5 to 10 minutes for the indexing to complete before you use the feature.
On the advanced code search page, you can search for code snippets, repositories, commits, and merge requests.