Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provided authentication credentials not taken into account when checking for open issues #17

Closed
hazcod opened this issue Apr 11, 2020 · 5 comments · Fixed by #100
Closed
Assignees
Labels
bug Something isn't working

Comments

@hazcod
Copy link
Contributor

hazcod commented Apr 11, 2020

Ongoing open issue has been identified #41
172
Alerts present in the current report: true
173
Process completed successfully and a new issue #42 has been created for the ZAP Scan.

https://github.com/ironPeakServices/ironpeak.be/runs/578941295?check_suite_focus=true

@thc202 thc202 added the bug Something isn't working label Apr 11, 2020
@sshniro
Copy link
Member

sshniro commented Apr 11, 2020

I assume this is due to the fact that the runner could not read the previous report and executing the create new issue workflow. I'll check and update you on this.

previousReport = await actionHelper.readPreviousReport(octokit, owner, repo, workSpace, previousRunnerID);

@sshniro
Copy link
Member

sshniro commented Apr 13, 2020

Hi @hazcod, I assume this is an isolated event, as the new scans (for 2 days) did not create a new issue: ironpeakservices/ironpeak.be#42

I will add more logs to figure out what went wrong.

@navpreet-securitas
Copy link

Hi
We are facing same issue , where GH issue is getting created again even though GH issue is present.
It works well when using default GITHUB_TOKEN , but if we use PAT token(with required permissions on repo) as below:

        id: baseline
        uses: zaproxy/action-baseline@v0.7.0
        with:
          token: ${{ secrets.ZAP_TOKEN }}
          target: 'https://www.example.com'
          rules_file_name: 'rules.tsv' 

it is not able to find existing open issue. Probably because of :
if ( issue["state"] === "open" && issue["user"]!["login"] === "github-actions[bot]" )
https://github.com/zaproxy/actions-common/blob/master/src/index.ts#LL73C1-L74C1

Since we are using PAT token it creates issue with another username in previous runs and username is verified as above it fails to get issue.
Why we are using PAT token instead of default GITHUB_TOKEN because we want to trigger another workflow which create jira ticket , whenever a GH issue is created by base zap scan workflow.
https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow

@sshniro any suggestions how to workaround this or fixes coming for this. maybe token can be used to identify user used for zap scan / issue creation and then verify that user in actions-common.

@navpreet-securitas
Copy link

navpreet-securitas commented May 11, 2023

Quoted message

Hi We are facing same issue , where GH issue is getting created again even though GH issue is present. It works well when using default GITHUB_TOKEN , but if we use PAT token(with required permissions on repo) as below:

        id: baseline
        uses: zaproxy/action-baseline@v0.7.0
        with:
          token: ${{ secrets.ZAP_TOKEN }}
          target: 'https://www.example.com'
          rules_file_name: 'rules.tsv' 

it is not able to find existing open issue. Probably because of : if ( issue["state"] === "open" && issue["user"]!["login"] === "github-actions[bot]" ) https://github.com/zaproxy/actions-common/blob/master/src/index.ts#LL73C1-L74C1

Since we are using PAT token it creates issue with another username in previous runs and username is verified as above it fails to get issue. Why we are using PAT token instead of default GITHUB_TOKEN because we want to trigger another workflow which create jira ticket , whenever a GH issue is created by base zap scan workflow. https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow

@sshniro any suggestions how to workaround this or fixes coming for this. maybe token can be used to identify user used for zap scan / issue creation and then verify that user in actions-common.

probably this can be used:
getting user by using token passed and then comparing with OR condition ( along with github-actions[bot])

// Octokit.js
// https://github.com/octokit/core.js#readme
const octokit = new Octokit({
  auth: 'YOUR-TOKEN'
})

await octokit.request('GET /user', {
  headers: {
    'X-GitHub-Api-Version': '2022-11-28'
  }
})

https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user

@thc202 thc202 changed the title Bug: new issue opened Provided authentication credentials not taken into account when checking for open issues Jun 30, 2023
thc202 added a commit to thc202/actions-common that referenced this issue Jul 2, 2023
Check the username of the authenticated user instead of always GitHub
Actions' bot to match the expected user, otherwise the issue would not
be found and it would be created a new one each time.

Part of zaproxy/action-baseline#17.

Signed-off-by: thc202 <thc202@gmail.com>
thc202 added a commit to thc202/actions-common that referenced this issue Jul 2, 2023
Check the username of the authenticated user instead of always GitHub
Actions' bot to match the expected user, otherwise the issue would not
be found and it would be created a new one each time.

Part of zaproxy/action-baseline#17.

Signed-off-by: thc202 <thc202@gmail.com>
thc202 added a commit to thc202/actions-common that referenced this issue Jul 2, 2023
Check the username of the authenticated user instead of always GitHub
Actions' bot to match the expected user, otherwise the issue would not
be found and it would be created a new one each time.

Part of zaproxy/action-baseline#17.

Signed-off-by: thc202 <thc202@gmail.com>
thc202 added a commit to thc202/action-baseline that referenced this issue Jul 3, 2023
Update `actions-common-scans` to latest version to fix zaproxy#17.
Update changelog and readme for release.

Signed-off-by: thc202 <thc202@gmail.com>
@thc202 thc202 self-assigned this Jul 3, 2023
@Den4200
Copy link

Den4200 commented Jul 3, 2023

Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

5 participants