GitHub集成 MurphySec 实时代码安全检测

该文章介绍了如何将MurphySec代码安全检测工具集成到GitHubActions中,以便在每次代码更新时自动进行安全漏洞检查。用户需启用GitHubActions,设置权限,获取MurphySec的访问令牌,然后创建并配置Actions工作流。检测到的漏洞可以通过SARIF文件查看,提供详细信息和修复建议。
摘要由CSDN通过智能技术生成

将MurphySec代码安全检测工具集成到GitHub action中,可对每一次代码更新实时进行安全漏洞检测,并快速修复这些安全漏洞。

如果您使用过GitHub Actions 请直接按照第3步开始操作

效果图

GitHub集成 MurphySec 实时代码安全检测

GitHub集成 MurphySec 实时代码安全检测

未开启请点击Actions启用GitHub Actions

GitHub集成 MurphySec 实时代码安全检测

如展示如下图所示表示项目已开启Actions

GitHub集成 MurphySec 实时代码安全检测

进入项目页面配置Action权限

点击settings–>Actions–>General–>

勾选Read and write permissions

最下方勾选Allow GitHub Actions to create and approve pull requests

GitHub集成 MurphySec 实时代码安全检测

GitHub集成 MurphySec 实时代码安全检测

登录murphysec官网获取token

设置–>访问令牌–>点击复制按钮

GitHub集成 MurphySec 实时代码安全检测

添加MURPHYSEC_TOKEN

点击仓库settings–>Secrets and variables–>Actons–>New repository secret

GitHub集成 MurphySec 实时代码安全检测

创建变量name:MURPHYSEC_TOKEN secrets:murphysec官网复制的TOKEN

GitHub集成 MurphySec 实时代码安全检测

创建GitHub Actions

点击项目Actions–>New workflows

GitHub集成 MurphySec 实时代码安全检测

点击set up a workflow yourself

GitHub集成 MurphySec 实时代码安全检测

添加ci代码并提交

GitHub集成 MurphySec 实时代码安全检测

GitHub Actions代码

branches:对应的分支,需要自行修改需要执行检测的分支名称

name: "MurphySec code scan"
on:
  push:
    branches:
      - master
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout_Actions
        uses: actions/checkout@v3
      - name: Install MurphySec code scan cli
        run: |
          wget -q https://s.murphysec.com/release/install.sh -O - | /bin/bash
      - name: Code scan
        run: murphysec  scan . --token ${{ secrets.MURPHYSEC_TOKEN }} --json >scan_results.json
      - name: Format data
        run: | 
          wget https://s.murphysec.com/github_actions_format.py
          python3 github_actions_format.py
      - name: Check if file exists
        run: |
          if [ -f "results.sarif" ]; then
            echo "file_exists=true" >> $GITHUB_ENV
          else
            echo "file_exists=false" >> $GITHUB_ENV
          fi
      - name: Upload SARIF file
        if: env.file_exists == 'true'
        uses: github/codeql-action/upload-sarif@v2
        with:
          sarif_file: results.sarif

查看代码检测结果

进入项目页面–>Security–>Code scanning

当前页面展示了所有风险组件的漏洞概览

GitHub集成 MurphySec 实时代码安全检测

点击要查看的漏洞标题可以进入详细信息页面,之后点击Show more查看详细信息

GitHub集成 MurphySec 实时代码安全检测

详细信息包含了漏洞的编号,处置建议,引入路径以及修复方案

点击项目检测报告下方链接可以跳转到murphysec官网查看更详细的漏洞信息

GitHub集成 MurphySec 实时代码安全检测

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值