본문 바로가기
개발/Git, GitHub

깃허브 액션 - is-website-vulnerable로 웹사이트 취약점 점검하기

by 피로물든딸기 2024. 4. 18.
반응형

Git / GitHub 전체 링크

 

참고

- https://github.com/lirantal/is-website-vulnerable

- github-pages-deploy-action로 리액트 gh-pages 자동 배포하기

 

인터넷 서점 알라딘취약점을 점검하는 깃허브 액션을 만들어 보자.

 

링크에 있는 예제를 리포지토리의 .github/workflows/check-website.yml에 추가한다.

name: Test site for publicly known js vulnerabilities

on: push
jobs:
  security:
    runs-on: ubuntu-latest
    steps:
      - name: Test for public javascript library vulnerabilities 
        uses: lirantal/is-website-vulnerable@main
        with:
          scan-url: "https://www.aladin.co.kr/home/welcome.aspx"

 

리포지토리에 push 이벤트가 발생하면 액션이 실행된 후, 아래의 결과를 얻을 수 있다.

24년 4월 17일 기준으로 알라딘 jQuery 취약점이 있는 것을 알 수 있다.


깃허브 페이지 배포 후 취약점 점검하기

 

여기서 조금 응용하면, 깃허브 액션으로 gh-pages를 배포한 후에 취약점을 점검할 수도 있다.

deploy가 성공하는 경우(if: success()) , 정상성을 점검하도록 scan-url깃허브 페이지의 주소로 변경하면 된다.

        ...

      - name: Deploy to GitHub Pages
        uses: JamesIves/github-pages-deploy-action@4.1.3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          branch: gh-pages 
          folder: build 

      - name: Test for public JavaScript library vulnerabilities
        if: success() # npm run deploy 성공 후 실행
        uses: lirantal/is-website-vulnerable@main
        with:
          scan-url: "your gh-pages url"

 

전체 코드는 다음과 같다.

name: Push and Deploy

on:
  push:
    branches:
      - master 

jobs:
  security:
    runs-on: ubuntu-latest

    permissions: 
      contents: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '16.19.0'

      - name: Install dependencies
        run: npm install # or npm install --legacy-peer-deps 

      - name: Build React app
        run: npm run build 

      - name: Deploy to GitHub Pages
        uses: JamesIves/github-pages-deploy-action@4.1.3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          branch: gh-pages 
          folder: build 

      - name: Test for public JavaScript library vulnerabilities
        if: success() # npm run deploy 성공 후 실행
        uses: lirantal/is-website-vulnerable@main
        with:
          scan-url: "YOUR GH-PAGES URL"

 

저장소에 push 되면 깃허브 액션이 제대로 실행되는지 확인해 보자.

반응형

댓글