OpenText Fortify SourceAnalyzer를 사용하여 Visual C/C++ 코드 분석하기

OpenText Fortify의 sourceanalyzer를 사용하여 Visual C/C++ 프로젝트를 분석하는 방법을 단계별로 설명드립니다.

1. 필수 준비 사항

  • Fortify SCA(Static Code Analyzer) 설치
  • Microsoft Visual Studio 설치 (해당 버전의 컴파일러 필요)
  • Windows 환경 (Linux/macOS에서는 Visual C++ 분석이 제한적)

2. 기본 분석 명령어

bash

sourceanalyzer -b <빌드ID> <컴파일러명> <컴파일옵션> <소스파일>

예시:

bash

sourceanalyzer -b MyProject cl /c /EHsc myfile.cpp

3. Visual Studio 프로젝트 분석 방법

방법 1: 명령줄에서 직접 컴파일

bash

sourceanalyzer -b MyProject -clean
sourceanalyzer -b MyProject msbuild MyProject.sln /p:Configuration=Release /p:Platform=x64

방법 2: Visual Studio 빌드 로그 사용

  1. 먼저 Visual Studio에서 빌드 로그 생성:textmsbuild MyProject.sln /t:rebuild /p:Configuration=Release /p:Platform=x64 /fl /flp:v=diag
  2. 로그 파일을 사용하여 분석:bashsourceanalyzer -b MyProject -vs-build-log msbuild.log

4. 고급 분석 옵션

분석 옵션 추가

bash

sourceanalyzer -b MyProject -scan -f results.fpr -Xmx4G -analysis-memory 4G

규칙 팩 지정

bash

sourceanalyzer -b MyProject -scan -f results.fpr -rules "Security Best Practices.xml"

병렬 분석

bash

sourceanalyzer -b MyProject -scan -f results.fpr -mt

5. 일반적인 문제 해결

컴파일러 경로 문제

bash

sourceanalyzer -b MyProject -vs-version 2019 msbuild MyProject.sln

64비트 모드 사용

bash

sourceanalyzer -64 -b MyProject msbuild MyProject.sln

PDB 파일 생성 문제

bash

sourceanalyzer -b MyProject -debug msbuild MyProject.sln

6. 분석 결과 확인

분석이 완료된 후 Fortify Audit Workbench로 결과 확인:

bash

AuditWorkbench results.fpr

주의사항

  1. Visual Studio 버전과 Fortify의 호환성 확인 필요
  2. 대형 프로젝트의 경우 충분한 메모리 할당(-Xmx 옵션)
  3. 정확한 분석을 위해 전체 리빌드 수행 권장
  4. Windows 환경에서 분석 시 Windows SDK 설치 확인

특정 프로젝트 구성에 따라 추가 옵션이 필요할 수 있습니다. 프로젝트의 복잡도에 따라 적절한 메모리 설정과 분석 시간을 고려해야 합니다.

위로 스크롤