[eslint-miner] feat(eslint): add prefer-core-logging rule#46195
Draft
github-actions[bot] wants to merge 3 commits into
Draft
[eslint-miner] feat(eslint): add prefer-core-logging rule#46195github-actions[bot] wants to merge 3 commits into
github-actions[bot] wants to merge 3 commits into
Conversation
Adds a new ESLint rule that flags console.log/error/warn/debug calls in scopes where an @actions/core alias (core / coreObj) is available. Rationale: - console.* bypasses GitHub Actions' secret masking: values passed to console.* are emitted verbatim to the workflow log, without the redaction that core.info/error/warning/debug applies. - core logging integrates with the Actions annotation system (error annotations, folded groups, etc.) while console.* does not. - The pattern appears in 5 locations in actions/setup/js, e.g. generate_workflow_overview.cjs:38 and merge_remote_agent_github_folder.cjs. Rule details: - Only flags when a CORE_ALIASES binding (core / coreObj) is in scope, preventing false positives in plain scripts that don't use @actions/core. - Covers: console.log → core.info, console.error → core.error, console.warn → core.warning, console.debug → core.debug, console.info → core.info. - Provides an auto-fix suggestion for each violation. - 11 unit tests (all passing). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
|
@copiliot always favor using core.... since we have a shim.cjs file to also support node.js context. |
Collaborator
|
@copilot always favor using core.... since we have a shim.cjs file to also support node.js context. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…n setup/js The shim.cjs provides global.core in all Node.js contexts, so console.* should never be used — remove hasCoreInScope() scope restriction from the rule and fix all console.* calls in the files mentioned in the PR. Changes: - prefer-core-logging.ts: remove hasCoreInScope() function and check; flag all console.* calls unconditionally; update description/suggestion message to reflect global.core availability via shim.cjs - prefer-core-logging.test.ts: update formerly-valid cases to expect errors; add suggestions to new invalid test cases (11 tests still pass) - generate_workflow_overview.cjs: console.log → core.info (core is a param) - generate_usage_activity_summary.cjs: require shim.cjs + console.log → core.info - merge_remote_agent_github_folder.cjs: require shim.cjs; remove local coreObj fallback that used console.*; replace all coreObj.* → core.* Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Done in commit
|
Contributor
Author
🤖 PR Triage
Adds new ESLint miner rule Batch:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new ESLint rule
prefer-core-loggingthat flagsconsole.*calls in scopes where an@actions/corealias (core/coreObj) is available.Rationale
console.*in GitHub Actions bypasses the runtime's built-in secret masking — values are emitted verbatim to the workflow log without redaction.core.info/core.error/core.warning/core.debugapply masking and integrate with the Actions annotation system.This pattern was observed in
actions/setup/jsacross multiple files:generate_workflow_overview.cjsconsole.log("Generated workflow overview...")generate_usage_activity_summary.cjsconsole.log/warn/errorin core-aware scopemerge_frontmatter_models.cjsconsole.login core-aware scopemerge_remote_agent_github_folder.cjsconsole.log/warn/erroradapter wrapping coreRule details
gh-aw-custom/prefer-core-loggingwarnCORE_ALIASESbinding (core/coreObj) is demonstrably in scope — no false positives on plain scripts without@actions/core.console.log/info → core.info,console.error → core.error,console.warn → core.warning,console.debug → core.debugValidation
Files changed
eslint-factory/src/rules/prefer-core-logging.ts— rule implementationeslint-factory/src/rules/prefer-core-logging.test.ts— 11 unit testseslint-factory/src/index.ts— rule registrationeslint-factory/eslint.config.cjs— rule enabled atwarn