Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
ad27f8a
update: add installation documentation
cyberchen1995 Jan 29, 2024
f4c0662
del: delete parameter explanations file
cyberchen1995 Jan 29, 2024
7be1851
update: add configuration and parameters documentation
cyberchen1995 Jan 29, 2024
53ee5fa
update: add database field descriptions
cyberchen1995 Jan 29, 2024
8fa7ac1
update: add vulnerability database configuration example
cyberchen1995 Jan 29, 2024
2cb385e
update: add dependency analysis
cyberchen1995 Feb 3, 2024
0cee1ae
Merge branch 'docs' of https://github.com/SuperChen-CC/OpenSCA-cli in…
cyberchen1995 Feb 3, 2024
c3e3eb1
update: add dependency analysis
cyberchen1995 Feb 3, 2024
0edf864
update: add dependency analysis
cyberchen1995 Feb 3, 2024
5016beb
update: add dependency analysis
cyberchen1995 Feb 3, 2024
9c2b7cf
update: add dependency analysis
cyberchen1995 Feb 3, 2024
ff35441
update: add Vulnerability Analysis documentation
cyberchen1995 Feb 6, 2024
db7b3d7
Merge branch 'XmirrorSecurity:master' into docs
cyberchen1995 Feb 6, 2024
7020498
update: IDE plugins documentation
cyberchen1995 Feb 22, 2024
2a31fc8
update: IDE plugins documentation
cyberchen1995 Feb 22, 2024
0bb4277
update: add dependency analysis documentation
cyberchen1995 Apr 1, 2024
a36c177
Merge branch 'XmirrorSecurity:master' into docs
cyberchen1995 Apr 1, 2024
fc02e18
Merge branch 'XmirrorSecurity:master' into docs
cyberchen1995 Apr 8, 2024
744bede
Merge branch 'XmirrorSecurity:master' into docs
cyberchen1995 Apr 9, 2024
cda1260
feat: add OpenSCA Scan Action
cyberchen1995 Jun 11, 2024
fa960f1
feat: add OpenSCA Scan Action
cyberchen1995 Jun 11, 2024
9828746
feat: add OpenSCA Scan Action
cyberchen1995 Jun 11, 2024
2cb2a7c
feat: add OpenSCA Scan Action
cyberchen1995 Jun 11, 2024
933ade5
feat: add OpenSCA Scan Action
cyberchen1995 Jun 11, 2024
1830bae
feat: add OpenSCA Scan Action
cyberchen1995 Jun 11, 2024
0b835e4
feat: add OpenSCA Scan Action
cyberchen1995 Jun 11, 2024
458d4e0
Merge pull request #294 from SuperChen-CC/scan-action
cyberchen1995 Jun 11, 2024
10ec3c3
fix: modify incorrect parameter use
cyberchen1995 Jun 11, 2024
947500f
Merge pull request #295 from XmirrorSecurity/SuperChen-CC-patch-1
cyberchen1995 Jun 11, 2024
5f4bc3d
fix: mvn download
luotianqi777 Jun 28, 2024
79bd286
Merge pull request #297 from luotianqi777/fix_mvn
cyberchen1995 Jun 28, 2024
5b5c2c5
fix: check out invalid npm components
luotianqi777 Jul 4, 2024
8131d43
Merge pull request #298 from luotianqi777/fix_js
cyberchen1995 Jul 4, 2024
2188590
fix: parse dsdx empty
luotianqi777 Jul 9, 2024
caff3e3
Merge pull request #300 from luotianqi777/fix_dsdx
cyberchen1995 Jul 9, 2024
4f37cae
fix: json2excel
luotianqi777 Jul 10, 2024
9fd7a95
Merge pull request #301 from luotianqi777/fix_script
cyberchen1995 Jul 10, 2024
91f4d3e
docs: update wechat qr code
cyberchen1995 Jul 22, 2024
4468b95
Merge branch 'XmirrorSecurity:master' into docs
cyberchen1995 Jul 26, 2024
e8cf6d6
chore: Update IDE plugin installation instructions
cyberchen1995 Jul 29, 2024
2e3581a
chore: Update report doc
cyberchen1995 Jul 29, 2024
a6cb31c
chore: insert table of content
cyberchen1995 Jul 29, 2024
affde33
chore: insert table of content
cyberchen1995 Jul 29, 2024
32e7de3
chore: Update SBOM and Reports doc
cyberchen1995 Jul 29, 2024
834daa2
Merge pull request #276 from SuperChen-CC/docs
cyberchen1995 Jul 29, 2024
33356a5
chore: Update SBOM generation documentation and add SaaS service info…
cyberchen1995 Jul 29, 2024
0e41c4a
chore: update downloaded instructions with gitcode
cyberchen1995 Sep 6, 2024
2d3f918
fix: dsdx nil pointer panic
luotianqi777 Sep 20, 2024
21e7581
Merge pull request #302 from luotianqi777/fix_dsdx
cyberchen1995 Oct 11, 2024
93d1f67
chore: Fix typo in install.sh script
cyberchen1995 Oct 11, 2024
163e6c3
Merge pull request #304 from SuperChen-CC/docs
cyberchen1995 Oct 11, 2024
afd4143
docs: 强调漏洞库version必须为范围
luotianqi777 Dec 3, 2024
eb0e7e9
feat: support dpsbom
luotianqi777 Jan 17, 2025
afb22dc
Merge pull request #305 from luotianqi777/master
cyberchen1995 Jan 17, 2025
ff03ff4
Merge pull request #307 from luotianqi777/dpsbom
cyberchen1995 Jan 17, 2025
be534bb
docs: Fix punctuation formatting in Chinese links in the Contributor'…
cyberchen1995 Jan 22, 2025
fd9fa5a
chore: Modify the return type of Statis() to optimize the output styl…
cyberchen1995 Jan 27, 2025
bd50c8e
Merge branch 'cc-dev' of https://github.com/SuperChen-CC/OpenSCA-cli …
cyberchen1995 Jan 27, 2025
0c48ab9
Merge branch 'XmirrorSecurity:master' into cc-dev
cyberchen1995 Jan 27, 2025
2c09408
Merge pull request #308 from cyberchen1995/cc-dev
cyberchen1995 Jan 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/run_opensca_scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: OpenSCA Scan

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:


jobs:
opensca_scan:
name: OpenSCA Scan
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
cmd/
opensca/
go.mod
main.go
- name: Run OpenSCA Scan
uses: XmirrorSecurity/opensca-scan-action@v1
with:
token: ${{ secrets.OPENSCA_TOKEN }}
proj: ${{ secrets.OPENSCA_PROJECT_ID }}
need-artifact: true
out: "outputs/results.json,outputs/result.html"
44 changes: 24 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

## 下载安装

1. 从 [github](https://github.com/XmirrorSecurity/OpenSCA-cli/releases) 或 [gitee](https://gitee.com/XmirrorSecurity/OpenSCA-cli/releases) 下载对应系统架构的可执行文件压缩包
1. 从 [github](https://github.com/XmirrorSecurity/OpenSCA-cli/releases) 或 [gitee](https://gitee.com/XmirrorSecurity/OpenSCA-cli/releases) 或 [gitcode](https://gitcode.com/XmirrorSecurity/OpenSCA-cli/releases) 下载对应系统架构的可执行文件压缩包

2. 或者下载源码编译(需要 `go 1.18` 及以上版本)

Expand All @@ -70,10 +70,14 @@
git clone https://github.com/XmirrorSecurity/OpenSCA-cli.git opensca && cd opensca && go build
// gitee linux/mac
git clone https://gitee.com/XmirrorSecurity/OpenSCA-cli.git opensca && cd opensca && go build
// gitcode linux/mac
git clone https://gitcode.com/XmirrorSecurity/OpenSCA-cli.git opensca && cd opensca && go build
// github windows
git clone https://github.com/XmirrorSecurity/OpenSCA-cli.git opensca ; cd opensca ; go build
// gitee windows
git clone https://gitee.com/XmirrorSecurity/OpenSCA-cli.git opensca ; cd opensca ; go build
// gitcode windows
git clone https://gitcode.com/XmirrorSecurity/OpenSCA-cli.git opensca ; cd opensca ; go build
```

默认生成当前系统架构的程序,如需生成其他系统架构可配置环境变量后编译
Expand Down Expand Up @@ -191,25 +195,25 @@ docker run -ti --rm -v ${PWD}:/src opensca/opensca-cli -token ${put_your_token_h

### 漏洞库字段说明

| 字段 | 描述 | 是否必填 |
| :------------------ | :-------------------------------- | :------- |
| `vendor` | 组件厂商 | 否 |
| `product` | 组件名 | 是 |
| `version` | 漏洞影响版本 | 是 |
| `language` | 组件语言 | 是 |
| `name` | 漏洞名 | 否 |
| `id` | 自定义编号 | 是 |
| `cve_id` | cve 编号 | 否 |
| `cnnvd_id` | cnnvd 编号 | 否 |
| `cnvd_id` | cnvd 编号 | 否 |
| `cwe_id` | cwe 编号 | 否 |
| `description` | 漏洞描述 | 否 |
| `description_en` | 漏洞英文描述 | 否 |
| `suggestion` | 漏洞修复建议 | 否 |
| `attack_type` | 攻击方式 | 否 |
| `release_date` | 漏洞发布日期 | 否 |
| `security_level_id` | 漏洞风险评级(1~4 风险程度递减) | 否 |
| `exploit_level_id` | 漏洞利用评级(0:不可利用,1:可利用) | 否 |
| 字段 | 描述 | 是否必填 |
| :------------------ | :--------------------------------------- | :------- |
| `vendor` | 组件厂商 | 否 |
| `product` | 组件名 | 是 |
| `version` | 漏洞影响版本(必须为范围,不能填单个版本) | 是 |
| `language` | 组件语言 | 是 |
| `name` | 漏洞名 | 否 |
| `id` | 自定义编号 | 是 |
| `cve_id` | cve 编号 | 否 |
| `cnnvd_id` | cnnvd 编号 | 否 |
| `cnvd_id` | cnvd 编号 | 否 |
| `cwe_id` | cwe 编号 | 否 |
| `description` | 漏洞描述 | 否 |
| `description_en` | 漏洞英文描述 | 否 |
| `suggestion` | 漏洞修复建议 | 否 |
| `attack_type` | 攻击方式 | 否 |
| `release_date` | 漏洞发布日期 | 否 |
| `security_level_id` | 漏洞风险评级(1~4 风险程度递减) | 否 |
| `exploit_level_id` | 漏洞利用评级(0:不可利用,1:可利用) | 否 |

本地漏洞库中`language`字段设定值包含`java、javascript、golang、rust、php、ruby、python`

Expand Down
117 changes: 117 additions & 0 deletions cmd/format/dpsbom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package format

import (
"archive/zip"
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"hash"
"io"
"path/filepath"
"strings"

"github.com/xmirrorsecurity/opensca-cli/v3/cmd/detail"
"github.com/xmirrorsecurity/opensca-cli/v3/opensca/model"
)

func DpSbomZip(report Report, out string) {
zipFile := out
if !strings.HasSuffix(out, ".zip") {
zipFile = out + ".zip"
}
jsonName := filepath.Base(out)
if !strings.HasSuffix(jsonName, ".json") {
jsonName = jsonName + ".json"
}
outWrite(zipFile, func(w io.Writer) error {
doc := pdSbomDoc(report)
if doc.Hashes.HashFile == "" {
return errors.New("hash file is required")
}

var h hash.Hash
switch strings.ToLower(doc.Hashes.Algorithm) {
case "sha-256":
h = sha256.New()
case "sha-1":
h = sha1.New()
case "md5":
h = md5.New()
case "":
return errors.New("hash algorithm is required")
default:
return fmt.Errorf("unsupported hash algorithm: %s", doc.Hashes.Algorithm)
}

tojson := func(w io.Writer) error {
encoder := json.NewEncoder(w)
encoder.SetIndent("", " ")
return encoder.Encode(doc)
}

zipfile := zip.NewWriter(w)
defer zipfile.Close()

sbomfile, err := zipfile.Create(jsonName)
if err != nil {
return err
}
err = tojson(sbomfile)
if err != nil {
return err
}

hashfile, err := zipfile.Create(doc.Hashes.HashFile)
if err != nil {
return err
}
err = tojson(h)
if err != nil {
return err
}
hashstr := hex.EncodeToString(h.Sum(nil)[:])
hashfile.Write([]byte(hashstr))

return nil
})
}

func pdSbomDoc(report Report) *model.DpSbomDocument {

doc := model.NewDpSbomDocument(report.TaskInfo.AppName, "opensca-cli")

report.DepDetailGraph.ForEach(func(n *detail.DepDetailGraph) bool {

if n.Name == "" {
return true
}

lics := []string{}
for _, lic := range n.Licenses {
lics = append(lics, lic.ShortName)
}
doc.AppendComponents(func(dsp *model.DpSbomPackage) {
dsp.Identifier.Purl = n.Purl()
dsp.Name = n.Name
dsp.Version = n.Version
dsp.License = lics
})

children := []string{}
for _, c := range n.Children {
if c.Name == "" {
continue
}
children = append(children, c.Purl())
}
doc.AppendDependencies(n.Purl(), children)

return true
})

return doc
}
10 changes: 10 additions & 0 deletions cmd/format/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ func Save(report Report, output string) {
switch filepath.Ext(out) {
case ".html":
Html(genReport(report), out)
case ".zip":
if strings.HasSuffix(out, ".dpsbom.zip") {
DpSbomZip(report, out)
} else {
Json(genReport(report), out)
}
case ".json":
if strings.HasSuffix(out, ".spdx.json") {
SpdxJson(report, out)
Expand All @@ -48,9 +54,13 @@ func Save(report Report, output string) {
CycloneDXJson(report, out)
} else if strings.HasSuffix(out, ".swid.json") {
SwidJson(report, out)
} else if strings.HasSuffix(out, ".dpsbom.json") {
DpSbomZip(report, out)
} else {
Json(genReport(report), out)
}
case ".dpsbom":
DpSbomZip(report, out)
case ".dsdx":
Dsdx(report, out)
case ".spdx":
Expand Down
15 changes: 8 additions & 7 deletions cmd/format/statis.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// Statis 统计概览信息
func Statis(report Report) string {
func Statis(report Report) (string, string) {

// 组件风险统计 key:0代表组件总数
depStatic := map[int]int{
Expand Down Expand Up @@ -50,10 +50,11 @@ func Statis(report Report) string {

return true
})

return fmt.Sprintf("Components:%d C:%d H:%d M:%d L:%d\n"+
"Vulnerabilities:%d C:%d H:%d M:%d L:%d",
depStatic[0], depStatic[1], depStatic[2], depStatic[3], depStatic[4],
vulStatic[0], vulStatic[1], vulStatic[2], vulStatic[3], vulStatic[4],
)
if vulStatic[0] != 0 {
return fmt.Sprintf("Components:%d C:%d H:%d M:%d L:%d",
depStatic[0], depStatic[1], depStatic[2], depStatic[3], depStatic[4]),
fmt.Sprintf("\nVulnerabilities:%d C:%d H:%d M:%d L:%d",
vulStatic[0], vulStatic[1], vulStatic[2], vulStatic[3], vulStatic[4])
}
return fmt.Sprintf("Components: %d", depStatic[0]), ""
}
3 changes: 2 additions & 1 deletion cmd/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ func OpenUI(report format.Report) {
}

func TaskInfo(report format.Report) *tview.TextView {
dep, vul := format.Statis(report)
info := tview.NewTextView().
SetText(format.Statis(report))
SetText(fmt.Sprintf("%s\n%s", dep, vul))
info.SetTextColor(tcell.ColorBlue)
return info
}
Expand Down
2 changes: 1 addition & 1 deletion docs/Contributing_Guideline-v1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ We appreciate all the contributions to OpenSCA.

Thanks again for your interest in OpenSCA and your support for our solution to open source vulnerabilities.

For the Chinese version of our contributing guideline, please check [贡献指南中文版v1.0](./Contributing_Guideline-v1.0-zh_CN.md)。
For the Chinese version of our contributing guideline, please check [贡献指南(中文版)v1.0](./Contributing_Guideline-v1.0-zh_CN.md)。
Loading
Loading