Azure DevOps용 GitHub Advanced Security에서 종속성 검사 문제를 해결하는 방법을 알아봅니다.
필수 조건
| 카테고리 | 요구 사항 |
|---|---|
| 권한 | - 리포지토리에 대한 모든 경고 요약을 보려면 기여자 권한이 필요합니다. - 고급 보안에서 경고를 해제하려면 : 프로젝트 관리자 권한입니다. - 고급 보안에서 사용 권한을 관리하려면: 프로젝트 컬렉션 관리자 그룹 또는 고급 보안의 구성원: 허용으로 설정된 설정 권한을 관리합니다. |
고급 보안 권한에 대한 자세한 내용은 고급 보안 권한 관리를 참조하세요.
수동 종속성 검사 작업 설정
팁 (조언)
가장 정확한 검색 결과를 얻으려면 검색하려는 코드를 빌드하는 파이프라인에서 빌드 단계 또는 패키지 복원 단계 후에 종속성 검사 작업을 추가합니다.
고급 보안 종속성 검사 작업(AdvancedSecurity-Dependency-Scanning@1)을 YAML 파이프라인 파일에 직접 추가하거나 작업 도우미에서 고급 보안 종속성 검사 작업을 선택합니다.
구성 요소를 식별하지 않는 종속성 검사
구성 요소에 플래그를 지정하지 않고 종속성 검사 작업이 완료되고 알려진 취약성이 있는 구성 요소에 대한 경고를 생성하지 못하는 경우 작업 전에 AdvancedSecurity-Dependency-Scanning@1 패키지 복원 단계를 수행해야 합니다.
예를 들어 C#(.NET Core) 프로젝트의 경우 샘플 YAML 코드 조각은 다음과 같습니다.
- task: DotNetCoreCLI@2
displayName: 'Restore NuGet packages'
inputs:
command: 'restore'
projects: '**/*.csproj'
# If you are using a private package feed such as Azure Artifacts, you will need additional variables.
# For more information, see https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/dotnet-core-cli-v2?view=azure-pipelines
feedsToUse: 'select'
...
- task: AdvancedSecurity-Dependency-Scanning@1
JavaScript 프로젝트의 경우 샘플 YAML 코드 조각은 다음과 같습니다.
- task: Npm@1
displayName: 'npm install'
inputs:
command: 'install'
workingDir: '$(System.DefaultWorkingDirectory)'
- task: AdvancedSecurity-Dependency-Scanning@1
종속성 스캐닝 작업 시간 초과
제한 시간이 초과되기 전에 종속성 검사 작업이 실행되는 기본 시간은 300초 또는 5분입니다. 작업이 완료되기 전에 시간 초과되는 경우 파이프라인 변수 DependencyScanning.Timeout(예: DependencyScanning.Timeout: 600초를 나타내는 정수가 예상됨)를 설정할 수 있습니다. 기본 제한 시간인 300초 미만의 모든 항목은 아무런 영향을 주지 않습니다.
이 변수를 사용하려면 파이프라인 변수로 추가 DependencyScanning.Timeout 합니다.
- task: AdvancedSecurity-Dependency-Scanning@1
env:
DependencyScanning.Timeout: 600
스캔 디렉터리 조정
기본적으로 종속성 검사 작업은 Agent.BuildDirectory 디렉터리를 처리합니다. 검색 범위를 특정 폴더로 지정하려는 경우 분석하려는 빌드 에이전트의 디렉터리 파일 경로로 파이프라인 변수 DependencyScanning.SourcePath 를 설정할 수 있습니다. 동일한 파이프라인 작업의 여러 종속성 검사 태스크 실행은 지원되지 않습니다. 검사 경로의 범위가 하위 디렉터리로 지정되면 작업을 다시 추가하여 다른 디렉터리를 검색할 수 없습니다.
- task: AdvancedSecurity-Dependency-Scanning@1
env:
DependencyScanning.SourcePath: scan/code/path
의도하지 않은 리포지토리에 결과 게시하는 종속성 검사
한 리포지토리에 파이프라인 정의가 저장되어 있고 GitHub Advanced Security에서 검사할 소스 코드가 다른 리포지토리에 있는 경우 결과가 처리되어 잘못된 리포지토리에 제출되어 소스 코드 리포지토리가 아닌 파이프라인 정의가 포함된 리포지토리에 게시될 수 있습니다.
의도한 결과 라우팅을 사용하도록 설정하려면 리포지토리를 유추하여 작업 디렉터리의 리포지토리에서 게시하도록 파이프라인 환경 변수 advancedsecurity.publish.repository.infer: true 를 설정합니다.
trigger:
- main
resources:
repositories:
# PipelineRepo: The repository containing the pipeline definition.
# This is optional and only needed if you plan to reference files or scripts from this repo.
- repository: PipelineRepo
type: git
name: DevOpsPipelineRepo
ref: refs/heads/main
trigger:
- main
# SourceRepo: The repository where scanning and publishing will occur.
- repository: SourceRepo
type: git
name: code-to-analyze-repo
ref: refs/heads/main
trigger:
- main
jobs:
- job: "DependencyScan"
displayName: "Dependency Scanning with Inferred Publishing"
variables:
# Enable repository inference
advancedsecurity.publish.repository.infer: true
steps:
# Checkout the SourceRepo
- checkout: SourceRepo
# Perform Dependency Scanning
- task: AdvancedSecurity-Dependency-Scanning@1
displayName: "Analyze Dependencies for Vulnerabilities"
결과가 게시되는 위치를 조정할 때 종속성 검사 끌어오기 요청 주석 누락
만약 advancedsecurity.publish.repository.infer을(를) 사용하거나 대체 advancedsecurity.publish.repository을(를) 정의하고 있는 경우, 끌어오기 요청 주석이 예상대로 표시되도록 파일 경로를 정확히 결정하기 위해 DependencyScanning.SourcePath: $(System.DefaultWorkingDirectory)을(를) 설정해야 할 수 있습니다.
- task: AdvancedSecurity-Dependency-Scanning@1
env:
DependencyScanning.SourcePath: $(System.DefaultWorkingDirectory)
빌드 작업에 대한 중단 시나리오
종속성 검사 빌드 작업이 파이프라인의 성공적인 실행을 차단하고 빌드 작업을 긴급하게 건너뛰어야 하는 경우 파이프라인 변수 DependencyScanning.Skip: true를 설정할 수 있습니다.
종속성 검사 작업 권한
종속성 검사 빌드 작업은 파이프라인 ID를 사용하여 고급 보안 REST API를 호출합니다. 기본적으로 동일한 프로젝트의 파이프라인은 경고를 가져올 수 있습니다. 빌드 서비스 계정에서 해당 권한을 제거하거나 사용자 지정 설정이 있는 경우(예: 리포지토리와 다른 프로젝트에서 호스트되는 파이프라인) 이러한 권한을 수동으로 부여합니다.
파이프라인에서 사용되는 빌드 서비스 계정에 대한 권한을 부여 Advanced Security: View Alerts 합니다. 프로젝트 범위 파이프라인의 경우 [Project Name] Build Service ([Organization Name])컬렉션 범위 파이프라인은 다음과 같습니다 Project Collection Build Service ([Organization Name]).
관련 문서
- 코드 검색 설정
- 종속성 검사 설정하기
- 비밀 스캐닝 설정
- Azure DevOps용 GitHub 고급 보안 대해 알아봅니다.