CollabOps

Code Quality

코드 린팅, 정적 보안 분석, 시크릿 탐지

collabops/lint@v1

On-Premise: ❌ — 대체 권장: sast-scan@v1, secret-detect@v1

MegaLinter 기반 멀티언어 코드 린팅입니다. 60개 이상의 언어를 지원합니다.

InputRequiredDefaultDescription
enableNO""활성화할 린터 (쉼표 구분)
disableNO""비활성화할 린터 (쉼표 구분)
apply-fixesNO"false"자동 수정 적용 여부
working-directoryNO"/workspace/source"스캔 대상 디렉토리

예시

전체 언어 자동 감지 + 보고

jobs:
  lint:
    steps:
      - name: checkout
        uses: "collabops/checkout@v2"
        with:
          repo-url: "https://<collabops-host>/<workspace>/<repository>.git"
      # 변경된 파일을 감지해서 자동으로 적절한 린터 선택.
      - name: lint
        uses: "collabops/lint@v1"

특정 언어만 검사 (enable / disable)

jobs:
  lint:
    steps:
      - name: checkout
        uses: "collabops/checkout@v2"
        with:
          repo-url: "https://<collabops-host>/<workspace>/<repository>.git"
      - name: lint-typed
        uses: "collabops/lint@v1"
        with:
          # enable: 화이트리스트 (지정한 것만). 쉼표 구분, 대문자.
          enable: "TYPESCRIPT,YAML,DOCKERFILE"
          # disable: 블랙리스트 (지정한 것 제외). enable 과 동시 사용 가능.
          disable: "SPELL,COPYPASTE"

자동 수정 (apply-fixes)

jobs:
  lint-fix:
    steps:
      - name: checkout
        uses: "collabops/checkout@v2"
        with:
          repo-url: "https://<collabops-host>/<workspace>/<repository>.git"
      - name: lint-with-autofix
        uses: "collabops/lint@v1"
        with:
          enable: "TYPESCRIPT,JAVASCRIPT"
          # 포매터·자동 수정 가능한 린터에 한해 디스크에 수정 결과 반영.
          apply-fixes: "true"
      # 수정된 결과를 동일 워크플로우의 다른 Job 으로 전달.
      - name: upload-fixes
        uses: "collabops/upload-artifact@v2"
        with:
          name: lint-fixes
          path: .

포인트 — 가장 단순한 형태(with 없음)는 변경 파일 기준으로 적절한 린터를 자동 선택. enabledisable 은 함께 쓸 수 있고, 60+ 언어 키워드는 대문자(TYPESCRIPT, DOCKERFILE 등). apply-fixes: "true" 는 워크스페이스 파일을 수정하므로 commit/PR 자동화와 함께 쓸 때 유의.

collabops/sast-scan@v1

On-Premise: ✅ airgapped 호환

Semgrep 기반 정적 보안 분석(SAST)입니다. OWASP Top 10 등 보안 취약점을 탐지합니다.

InputRequiredDefaultDescription
configNO"auto"Semgrep 규칙 설정 (auto, p/python, p/javascript 또는 파일 경로)
severityNO"ERROR"최소 심각도 필터 (INFO, WARNING, ERROR)
output-formatNO"text"출력 형식 (text, json, sarif)
working-directoryNO"/workspace/source"스캔 대상 디렉토리

예시

기본 — auto 룰셋

jobs:
  sast:
    steps:
      - name: checkout
        uses: "collabops/checkout@v2"
        with:
          repo-url: "https://<collabops-host>/<workspace>/<repository>.git"
      # config: "auto" 가 기본 — 언어 감지 후 표준 룰셋 자동 선택.
      - name: sast-scan
        uses: "collabops/sast-scan@v1"

OWASP Top 10 + WARNING 이상 차단

jobs:
  sast:
    steps:
      - name: checkout
        uses: "collabops/checkout@v2"
        with:
          repo-url: "https://<collabops-host>/<workspace>/<repository>.git"
      - name: sast-owasp
        uses: "collabops/sast-scan@v1"
        with:
          # 표준 룰셋. Registry slug, 로컬 파일 경로, URL 모두 지원.
          config: p/owasp-top-ten
          # 이 수준 이상의 finding 이 있으면 Job 실패.
          severity: WARNING

SARIF 결과 + artifact 업로드

# 보고서를 실패에도 보존하려면 별도 Job 으로 분리 + Job 레벨 if: "always()".
jobs:
  sast:
    steps:
      - name: checkout
        uses: "collabops/checkout@v2"
        with:
          repo-url: "https://<collabops-host>/<workspace>/<repository>.git"
      - name: sast-with-sarif
        uses: "collabops/sast-scan@v1"
        with:
          config: p/security-audit
          # 보안 대시보드/리뷰 도구에 업로드 가능한 표준 포맷.
          output-format: sarif

  archive-sast-report:
    needs: [sast]
    # 이전 Job 의 성공/실패와 관계없이 항상 실행 — 보고서를 무조건 수집.
    if: "always()"
    steps:
      - name: archive-sarif
        uses: "collabops/upload-artifact@v2"
        with:
          name: sast-report
          path: semgrep-results.sarif

포인트config 는 Registry slug(p/owasp-top-ten), 로컬 경로, URL 모두 가능. severityINFO|WARNING|ERROR — 차단 임계점을 명확히. SARIF 결과는 if: always()upload-artifact 조합으로 실패 시에도 반드시 수집 권장.

collabops/secret-detect@v1

On-Premise: ✅ airgapped 호환

Gitleaks 기반 소스코드 시크릿 탐지입니다. API 키, 비밀번호 등 민감 정보를 검출합니다.

InputRequiredDefaultDescription
configNO""Gitleaks 설정 파일 경로 (.gitleaks.toml)
report-formatNO"json"리포트 형식 (json, csv, sarif, junit)
report-pathNO"/workspace/source/gitleaks-report.json"리포트 출력 경로
working-directoryNO"/workspace/source"스캔 대상 디렉토리

예시

기본 스캔 + JSON 보고서

jobs:
  secret-scan:
    steps:
      - name: checkout
        uses: "collabops/checkout@v2"
        with:
          repo-url: "https://<collabops-host>/<workspace>/<repository>.git"
          # 시크릿 스캔은 전 히스토리에 대해 실행 권장.
          fetch-depth: "0"
      - name: secret-detect
        uses: "collabops/secret-detect@v1"

커스텀 룰 + SARIF 결과 업로드

# 보고서 보존을 위해 별도 archive Job 분리.
jobs:
  secret-scan:
    steps:
      - name: checkout
        uses: "collabops/checkout@v2"
        with:
          repo-url: "https://<collabops-host>/<workspace>/<repository>.git"
          fetch-depth: "0"
      - name: secret-detect-with-rules
        uses: "collabops/secret-detect@v1"
        with:
          # 사내 룰셋이 리포에 같이 들어있는 경우.
          config: .gitleaks.toml
          report-format: sarif
          report-path: /workspace/source/gitleaks-report.sarif

  archive-secret-report:
    needs: [secret-scan]
    if: "always()"
    steps:
      - name: archive-report
        uses: "collabops/upload-artifact@v2"
        with:
          name: gitleaks-report
          path: gitleaks-report.sarif

포인트 — 시크릿 스캔은 fetch-depth: "0" 으로 전 히스토리 를 확인하는 것이 의미 있음 (shallow 체크아웃이면 누락). config 는 .gitleaks.toml 같은 사내 룰을 가리킬 수 있음 — 미지정 시 기본 룰. Finding 발생 시 Job 실패가 기본 동작 — if: always() 로 보고서를 무조건 수집.

collabops/sonar-scan@v1

On-Premise: ✅ airgapped 호환 (단, 파이프라인에서 도달 가능한 외부 SonarQube 서버 필요)

외부 SonarQube 서버에 코드 품질·보안 분석 결과를 업로드하는 정적 분석입니다. sonar-scanner CLI 가 이미지 번들 JRE 로 동작해 런타임 외부 다운로드가 없습니다.

InputRequiredDefaultDescription
sonar-host-urlYESSonarQube 서버 URL (SONAR_HOST_URL)
sonar-tokenYES인증 토큰 (secrets 주입 권장)
project-keyYES프로젝트 키 (sonar.projectKey)
sourcesNO"."분석 대상 소스 경로 (sonar.sources)
working-directoryNO"/workspace/source"스캔 실행 디렉토리 (sonar.projectBaseDir)
skip-jre-provisioningNO"true"이미지 번들 JRE 사용 (에어갭 안전, 런타임 다운로드 차단)
extra-argsNO""추가 sonar-scanner -D 옵션 passthrough

예시

기본 스캔

jobs:
  quality:
    steps:
      - name: checkout
        uses: "collabops/checkout@v2"
        with:
          repo-url: "https://<collabops-host>/<workspace>/<repository>.git"
      # 외부 SonarQube 서버로 분석 결과를 업로드. 서버 URL/토큰은 워크스페이스 설정에서 주입.
      - name: sonar-scan
        uses: "collabops/sonar-scan@v1"
        with:
          # SonarQube 서버 URL — 워크스페이스 variables 에 SONAR_HOST_URL 등록 후 참조.
          sonar-host-url: ${{ vars.SONAR_HOST_URL }}
          # 분석 토큰 — secrets 에 저장 (평문 입력 금지).
          sonar-token: ${{ secrets.SONAR_TOKEN }}
          # SonarQube 서버에 생성한 프로젝트 키.
          project-key: "<workspace>-<repository>"

Quality Gate 로 Change Request 차단

# CR 머지 게이트로 쓰려면 change_request 트리거 + qualitygate.wait 조합.
jobs:
  quality:
    steps:
      - name: checkout
        uses: "collabops/checkout@v2"
        with:
          repo-url: "https://<collabops-host>/<workspace>/<repository>.git"
      - name: sonar-scan
        uses: "collabops/sonar-scan@v1"
        with:
          sonar-host-url: ${{ vars.SONAR_HOST_URL }}
          sonar-token: ${{ secrets.SONAR_TOKEN }}
          project-key: "<workspace>-<repository>"
          # 서버 Quality Gate 결과를 기다렸다가 실패 시 step 을 실패시켜 머지를 차단.
          # (서버 측 프로젝트에 Quality Gate 가 설정돼 있어야 의미가 있다.)
          extra-args: "-Dsonar.qualitygate.wait=true"

extra-args 로 서버별 튜닝

jobs:
  quality:
    steps:
      - name: checkout
        uses: "collabops/checkout@v2"
        with:
          repo-url: "https://<collabops-host>/<workspace>/<repository>.git"
      - name: sonar-scan
        uses: "collabops/sonar-scan@v1"
        with:
          sonar-host-url: ${{ vars.SONAR_HOST_URL }}
          sonar-token: ${{ secrets.SONAR_TOKEN }}
          project-key: "<workspace>-<repository>"
          # 분석 대상 소스 경로 (working-directory 기준 상대경로).
          sources: "src"
          # 추가 -D 옵션 passthrough — 공백으로 여러 개 전달.
          extra-args: "-Dsonar.exclusions=**/*.test.ts -Dsonar.sourceEncoding=UTF-8"

포인트sonar-host-url·sonar-token·project-key 3개가 필수. 토큰은 반드시 secrets, 서버 URL 은 vars 로 주입(평문 금지). 에어갭 온프렘에서도 skip-jre-provisioning 기본값 true 로 런타임 다운로드 없이 동작하지만, 파이프라인 pod 에서 도달 가능한 SonarQube 서버는 필요합니다. CR 머지 차단은 extra-args: "-Dsonar.qualitygate.wait=true" + 서버 측 Quality Gate 설정 조합으로 구성합니다.

목차