Skip to content

Commit

Permalink
Merge pull request #64 from grom72/SRE-2505-trivy
Browse files Browse the repository at this point in the history
Sre 2505 trivy
  • Loading branch information
grom72 authored Oct 30, 2024
2 parents 6eb61d3 + c2cd42d commit 81e7931
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 51 deletions.
59 changes: 10 additions & 49 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# SPDX-License-Identifier: BSD-2-Clause-Patent
# Copyright (c) 2024 Intel Corporation.

name: Trivy scan

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
push:
branches: ["master", "release/**"]
pull_request:
Expand All @@ -11,59 +16,15 @@ on:
permissions: {}

jobs:
build:
name: Build
runs-on: ubuntu-20.04
scan:
name: Scan with Trivy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@6e7b7d1fd3e4fef0c5fa8cce1229c54b2c9bd0d8 # 0.24.0
with:
scan-type: 'fs'
scan-ref: '.'
trivy-config: 'utils/trivy/trivy.yaml'

- name: Prepare the report to be uploaded to the GitHub artifact store
run: |
mkdir report
cp trivy-report-daos.txt report
cp utils/trivy/.trivyignore report/trivyignore.txt
- name: Upload the report to the GitHub artifact store
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
path: report/*
name: trivy-report-daos

- name: Adjust config file to use sarif format
run: |
sed -i 's/output: "trivy-report-daos.txt"/output: "trivy-results.sarif"/g' \
utils/trivy/trivy.yaml
sed -i 's/format: template/format: sarif/g' utils/trivy/trivy.yaml
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@6e7b7d1fd3e4fef0c5fa8cce1229c54b2c9bd0d8 # 0.24.0
with:
scan-type: 'fs'
scan-ref: '.'
trivy-config: 'utils/trivy/trivy.yaml'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a
# 3.25.15 (v3)
with:
sarif_file: 'trivy-results.sarif'

- name: Adjust config file to show and validate scan results
run: |
sed -i 's/output: "trivy-results.sarif"//g' utils/trivy/trivy.yaml
sed -i 's/format: sarif/format: table/g' utils/trivy/trivy.yaml
sed -i 's/exit-code: 0/exit-code: 1/g' utils/trivy/trivy.yaml
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@6e7b7d1fd3e4fef0c5fa8cce1229c54b2c9bd0d8 # 0.24.0
- name: Run Trivy vulnerability scanner in filesystem mode (table format)
uses: grom72/trivy-action@skip-download
with:
scan-type: 'fs'
scan-ref: '.'
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![Build](https://github.com/daos-stack/daos/actions/workflows/ci2.yml/badge.svg)](https://github.com/daos-stack/daos/actions/workflows/ci2.yml)
[![Codespell](https://github.com/daos-stack/daos/actions/workflows/spelling.yml/badge.svg)](https://github.com/daos-stack/daos/actions/workflows/spelling.yml)
[![Doxygen](https://github.com/daos-stack/daos/actions/workflows/doxygen.yml/badge.svg)](https://github.com/daos-stack/daos/actions/workflows/doxygen.yml)
[![Trivy scan](https://github.com/daos-stack/daos/actions/workflows/trivy.yml/badge.svg)](https://github.com/daos-stack/daos/actions/workflows/trivy.yml)

<a href="https://docs.daos.io/">
<img src="https://avatars.githubusercontent.com/u/20561043?s=400&u=db7cd0ada987ba59c21c3de5f9e7cffba73c3325&v=4" width="200" height="200">
Expand Down
14 changes: 14 additions & 0 deletions src/container/container_iv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ cont_iv_hdl_fetch(uuid_t cont_hdl_uuid, uuid_t pool_uuid,
D_DEBUG(DB_TRACE, "Can not find "DF_UUID" hdl\n",
DP_UUID(cont_hdl_uuid));

invalidate_retry:
/* Fetch the capability from the leader. To avoid extra locks,
* all metadatas are maintained by xstream 0, so let's create
* an ULT on xstream 0 to let xstream 0 to handle capa fetch
Expand Down Expand Up @@ -1046,6 +1047,19 @@ cont_iv_hdl_fetch(uuid_t cont_hdl_uuid, uuid_t pool_uuid,
if (*cont_hdl == NULL) {
D_DEBUG(DB_TRACE, "Can not find "DF_UUID" hdl\n",
DP_UUID(cont_hdl_uuid));
/* In reintegrate with case that the IC_CONT_CAPA cache is valid locally
* but cont open handle invalid (not in dt_cont_hdl_hash). For this case
* invalidate local IV cache first and retry again, to avoid in-flight
* UPDATE's failure. (IV locally valid then the IV fetch will not trigger
* cont_iv_ent_update() callback).
*/
if (!invalidate_current) {
invalidate_current = true;
ABT_eventual_free(&eventual);
D_DEBUG(DB_TRACE, DF_UUID" invalidate_current and retry\n",
DP_UUID(cont_hdl_uuid));
goto invalidate_retry;
}
D_GOTO(out_eventual, rc = -DER_NONEXIST);
}

Expand Down
7 changes: 5 additions & 2 deletions src/object/cli_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -6310,7 +6310,9 @@ obj_ec_get_parity_or_alldata_shard(struct obj_auxi_args *obj_auxi, unsigned int
shard_idx = grp_start + i;
if (obj_shard_is_invalid(obj, shard_idx, DAOS_OBJ_RPC_ENUMERATE)) {
if (++fail_cnt > obj_ec_parity_tgt_nr(oca)) {
D_ERROR(DF_OID" reach max failure "DF_RC"\n",
D_ERROR(DF_CONT", obj "DF_OID" reach max failure "DF_RC"\n",
DP_CONT(obj->cob_pool->dp_pool,
obj->cob_co->dc_uuid),
DP_OID(obj->cob_md.omd_id), DP_RC(-DER_DATA_LOSS));
D_GOTO(out, shard = -DER_DATA_LOSS);
}
Expand Down Expand Up @@ -6457,7 +6459,8 @@ obj_list_shards_get(struct obj_auxi_args *obj_auxi, unsigned int map_ver,
}

if (rc < 0) {
D_ERROR(DF_OID" Can not find shard grp %d: "DF_RC"\n",
D_ERROR(DF_CONT", obj "DF_OID" Can not find shard grp %d: "DF_RC"\n",
DP_CONT(obj->cob_pool->dp_pool, obj->cob_co->dc_uuid),
DP_OID(obj->cob_md.omd_id), grp_idx, DP_RC(rc));
D_GOTO(out, rc);
}
Expand Down
3 changes: 3 additions & 0 deletions utils/trivy/trivy.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause-Patent
# Copyright (c) 2024 Intel Corporation.

cache:
backend: fs
dir:
Expand Down

0 comments on commit 81e7931

Please sign in to comment.