Skip to content

Conversation

@Abhinavpv28
Copy link
Contributor

No description provided.

@Abhinavpv28 Abhinavpv28 requested a review from a team as a code owner October 14, 2025 19:42
Comment on lines +12 to +28
name: Execute unit tests in dcm-agent GTest suite
runs-on: ubuntu-latest
container:
image: ghcr.io/rdkcentral/docker-rdk-ci:latest

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

- name: Run unit tests
run: sh unit_test.sh

- name: Upload test results to automatic test result management system
if: github.repository_owner == 'rdkcentral'
run: |
git config --global --add safe.directory `pwd`
gtest-json-result-push.py /tmp/Gtest_Report https://rdkeorchestrationservice.apps.cloud.comcast.net/rdke_orchestration_api/push_unit_test_results `pwd`

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 4 months ago

To fix the problem, the workflow YAML should be amended to explicitly specify the required permissions by adding a permissions block. The block can be placed at the root level (recommended, for future jobs) or directly inside the individual job. The minimal starting permissions should be contents: read, which allows the workflow only to read repository contents. There is no evidence that write permissions or other scopes (such as pull-requests: write) are needed for any step in the provided workflow.

Change required: In .github/workflows/L1-Test.yml, add the following beneath the workflow name near the top of the file:

permissions:
  contents: read

This change limits the default permissions available to the workflow and its jobs. No changes to imports, dependencies, secret/environment variable handling, or any step definition are needed.


Suggested changeset 1
.github/workflows/L1-Test.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/L1-Test.yml b/.github/workflows/L1-Test.yml
--- a/.github/workflows/L1-Test.yml
+++ b/.github/workflows/L1-Test.yml
@@ -1,4 +1,6 @@
 name: Unit tests dcm-agent
+permissions:
+  contents: read
 on:
   pull_request:
     branches: [ develop, main ]
EOF
@@ -1,4 +1,6 @@
name: Unit tests dcm-agent
permissions:
contents: read
on:
pull_request:
branches: [ develop, main ]
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +9 to +54
name: Test coverage report for release
runs-on: ubuntu-latest
container:
image: ghcr.io/rdkcentral/docker-rdk-ci:latest

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

- name: Run unit tests with coverage flags enabled
run: |
sh unit_test.sh --enable-cov
- name: Caculate the code coverage summary
run: |
cd ./unittest
lcov --list coverage.info | grep "Lines\|Total" > /tmp/coverage_summary.txt
cd -

- name: Update the coverage report to Pull request using actions
uses: actions/github-script@v4
with:
script: |
const fs = require('fs');
const lcov_result = fs.readFileSync('/tmp/coverage_summary.txt', 'utf8');

github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body:
'## Code Coverage Summary \n' +
' ' +
'```' +
lcov_result +
'```'
});
- name: Generate the html report
run: |
cd ./unittest
genhtml coverage.info --output-directory /tmp/coverage_report
cd -
- name: Upload the coverage report to Pull request using actions
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: /tmp/coverage_report

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 4 months ago

To fix the problem, we need to add a permissions block to the workflow. This permissions block should be at the top level, underneath the workflow name, or inside the affected job. In this case, since only the execute-unit-code-coverage-report-on-release job is present, we may add it either globally or inside that job. For clarity and extensibility, it is recommended to add it at the top level of the workflow. The required minimum permissions for this workflow are:

  • contents: read (for checking out code)
  • issues: write (to post results as comments on the PR via github.issues.createComment)

No other permissions are required. The edit should be made directly to the .github/workflows/code-coverage.yml file, immediately after the name field (i.e., after line 1). No imports or variable definitions are needed; simply add the block in the YAML file.

Suggested changeset 1
.github/workflows/code-coverage.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml
--- a/.github/workflows/code-coverage.yml
+++ b/.github/workflows/code-coverage.yml
@@ -1,4 +1,7 @@
 name: Code Coverage
+permissions:
+  contents: read
+  issues: write
 
 on:
   pull_request:
EOF
@@ -1,4 +1,7 @@
name: Code Coverage
permissions:
contents: read
issues: write

on:
pull_request:
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants