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

security: add permissions block to workflows #3875

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

reakaleek
Copy link
Member

Details

⚠️ This PR was created by an automated tool. Please review the changes carefully. ⚠️

We want to set the default permissions for workflows to read-only for contents.
This is a security measure to prevent accidental changes to the repository.

This change adds a top-level permissions block to all workflows in the .github/workflows directory.

permissions:
  contents: read

In some cases workflows might need more permissions than just contents: read.
Please checkout this branch and add the necessary permissions to the workflows.

If your workflow uses a Personal Access Token (PAT), we can still add the permissions block,
but it will not have any effect.

Merging this PR as is might cause workflows that need more permissions to fail.

If there are any questions, please reach out to the @elastic/observablt-ci

@reakaleek reakaleek self-assigned this Feb 17, 2024
@reakaleek reakaleek requested a review from a team February 17, 2024 18:58
@github-actions github-actions bot added the agent-nodejs Make available for APM Agents project planning. label Feb 17, 2024
@trentm trentm merged commit b43adff into main Feb 20, 2024
17 checks passed
@trentm trentm deleted the gh-oblt/add-permission-block-to-workflows branch February 20, 2024 19:29
Comment on lines +10 to +11
permissions:
contents: read
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I got review incorrect on this. This workflow needs write permission to the issue/PR to add a label. I'm not sure if that is being limited by this permissions: ... addition.

Recently two PRs have had this labeler workflow fail:
https://github.com/elastic/apm-agent-nodejs/actions/runs/8042135103/job/22024012622?pr=3882
https://github.com/elastic/apm-agent-nodejs/actions/runs/8042141883/job/21962393814?pr=3883

Run AlexanderWert/issue-labeler@v2.3
  with:
    repo-token: ***
    configuration-path: .github/labeler-config.yml
    enable-versioned-regex: 0
  env:
    MY_GITHUB_TOKEN: ***
Adding labels agent-nodejs to issue #3882
/home/runner/work/_actions/AlexanderWert/issue-labeler/v2.3/node_modules/@octokit/request/dist-node/index.js:66
        const error = new requestError.RequestError(message, status, {
                      ^

RequestError [HttpError]: Resource not accessible by integration
    at /home/runner/work/_actions/AlexanderWert/issue-labeler/v2.3/node_modules/@octokit/request/dist-node/index.js:66:23
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  status: 403,
  headers: {
    'access-control-allow-origin': '*',
    'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
    connection: 'close',
    'content-encoding': 'gzip',
    'content-security-policy': "default-src 'none'",
    'content-type': 'application/json; charset=utf-8',
    date: 'Tue, 27 Feb 2024 10:12:23 GMT',
    'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
    server: 'GitHub.com',
    'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
    'transfer-encoding': 'chunked',
    vary: 'Accept-Encoding, Accept, X-Requested-With',
    'x-accepted-github-permissions': 'issues=write; pull_requests=write',
    'x-content-type-options': 'nosniff',
    'x-frame-options': 'deny',
    'x-github-api-version-selected': '2022-11-28',
    'x-github-media-type': 'github.v3; format=json',
    'x-github-request-id': 'D084:4803:180CFA2:2FA3CB1:65DDB587',
    'x-ratelimit-limit': '15000',
    'x-ratelimit-remaining': '14998',
    'x-ratelimit-reset': '1709032343',
    'x-ratelimit-resource': 'core',
    'x-ratelimit-used': '2',
    'x-xss-protection': '0'
  },
  request: {
    method: 'POST',
    url: 'https://api.github.com/repos/elastic/apm-agent-nodejs/issues/3882/labels',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit.js/16.43.2 Node.js/16.20.2 (Linux 6.2; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: '{"labels":["agent-nodejs"]}',
    request: {
      hook: [Function: bound bound register],
      validate: {
        issue_number: { required: true, type: 'integer' },
        labels: { required: true, type: 'string[]' },
        number: { alias: 'issue_number', deprecated: true, type: 'integer' },
        owner: { required: true, type: 'string' },
        repo: { required: true, type: 'string' }
      }
    }
  },
  documentation_url: 'https://docs.github.com/rest/issues/labels#add-labels-to-an-issue'
}

I don't know that this is about this change, but it seems related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-nodejs Make available for APM Agents project planning.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants