Skip to content

✨ QD-13415 Exchange organization API token for a project token - #1052

Open
Theodor Port (taport) wants to merge 2 commits into
mainfrom
port/QD-13415-exchange-org-api-token
Open

Theodor Port (taport) wants to merge 2 commits into
mainfrom
port/QD-13415-exchange-org-api-token

Conversation

@taport

Copy link
Copy Markdown
Contributor

Users can supply QODANA_ORG_TOKEN plus a project slug (team-slug:project-slug) from QODANA_PROJECT_SLUG or 'projectSlug:' in qodana.yaml instead of QODANA_TOKEN. At startup the CLI exchanges them via the Qodana Public API (POST /public/organizations/projects) for a project token valid for 6 hours.

  • the linter/container only ever sees the project token via QODANA_TOKEN
  • QODANA_ORG_TOKEN is removed from the process env, container env and debug output
  • the exchanged token is never saved to the keyring
  • each slug part must be 3-64 chars of letters, digits, space, '-', '.', '_'

Checklist

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My commit messages are styled with gitmoji
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Users can supply QODANA_ORG_TOKEN plus a project slug (team-slug:project-slug)
from QODANA_PROJECT_SLUG or 'projectSlug:' in qodana.yaml instead of QODANA_TOKEN.
At startup the CLI exchanges them via the Qodana Public API
(POST /public/organizations/projects) for a project token valid for 6 hours.

- the linter/container only ever sees the project token via QODANA_TOKEN
- QODANA_ORG_TOKEN is removed from the process env, container env and debug output
- the exchanged token is never saved to the keyring
- each slug part must be 3-64 chars of letters, digits, space, '-', '.', '_'

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@taport
Theodor Port (taport) requested a review from a team as a code owner September 23, 2026 14:41
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T14:46:40.177333Z fb0074a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb0074a386

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread internal/cmd/scan.go
`,
Run: func(cmd *cobra.Command, args []string) {
qdenv.InitializeQodanaGlobalEnv(cliOptions)
tokenloader.InitializeQodanaGlobalEnv(cliOptions, cliOptions.ProjectDir, cliOptions.ConfigName)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Scrub the organization token from the scan context

When the token is supplied through the supported --env QODANA_ORG_TOKEN=... path, this call resolves it but only removes the OS-environment copy; the original value remains in cliOptions.Env_. CreateContext copies that slice into the scan context, and RunAnalysis passes every context field to platform.LogContext, so debug logging prints the organization-level secret before getDockerOptions filters it from the container environment. Remove or redact this entry before constructing/logging the context.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 21bd12a: QODANA_ORG_TOKEN is now removed from cliOptions.Env_ right after the token is resolved, in scan.go and in the third-party run.go. It never reaches corescan.Context or LogContext. The container env and the debug docker run command were already filtered.

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Qodana for Go

139 new problems were found

Inspection name Severity Problems
Check dependency licenses 🔴 Failure 5
Vulnerable declared dependency 🔴 Failure 1
Check GO source code coverage 🔶 Warning 74
Unhandled error 🔶 Warning 13
Potential resource leak 🔶 Warning 6
Check dependency licenses 🔶 Warning 4
Deprecated element 🔶 Warning 4
Imported package name as a name identifier 🔶 Warning 3
Reserved word used as name 🔶 Warning 1
Vulnerable declared dependency 🔶 Warning 1
Unsorted imports ◽️ Notice 13
Name starts with a package name ◽️ Notice 8
Empty slice declared using a literal ◽️ Notice 3
Comment of exported element starts with the incorrect name ◽️ Notice 1
Redundant type conversion ◽️ Notice 1
Vulnerable declared dependency ◽️ Notice 1
@@ Code coverage @@
+ 64% total lines covered
11680 lines analyzed, 7546 lines covered
# Calculated according to the filters of your coverage tool

☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

- rename OrgTokenDeclinedError to ErrOrgTokenDeclined (ST1012)
- don't end the declined error format string with punctuation (ST1005)
- drop QODANA_ORG_TOKEN from --env options after resolution so it never
  reaches the scan context and its debug output
- move env filtering helpers to qdenv

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

1 participant