ballerina:13 reports boolean strings, auth scheme names and qualified secret names

未关闭
#178 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@TharmiganK 已经在做这个了。

开始于 2026年11月10日。

  • #180 来自 @TharmiganK —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java

调研方向

Start with the ballerina:13 rule implementation and its tests, especially the tests for #109 and the ballerina/http cases mentioned in the issue. Check how it recognizes boolean strings, authentication scheme values, and secret-like target names. Add coverage for the listed examples and confirm they are no longer reported while other hard-coded secrets still are.

由索引模型根据 Issue 内容生成。

描述

Area/Rules Type/Bug
Description

Rule ballerina:13 (Hard-coded secrets) reports string values that are not secrets, because the name of the target contains a secret-like word. #109 fixed boolean values, values built from configurables, and protocol keywords such as access_token. These forms are still reported:

import ballerina/http;

// 1. A boolean as a string, for the CORS `Access-Control-Allow-Credentials` header value
function assertCors(http:Response response, string credentials) {
}

// 2. A variable whose name only qualifies the secret word
function proxyStatus(http:Request req) returns string {
    string hasAuthHeader = "No Proxy";
    if req.hasHeader("Proxy-Authorization") {
        hasAuthHeader = "Proxy";
    }
    return hasAuthHeader;
}

// 3. An authentication scheme name with no credential
function incompleteHeaders() returns [string, map<string>] {
    string incompleteBasicAuth = "Basic";
    return [incompleteBasicAuth, {"authorization": "Basic "}];
}

public function main() {
    assertCors(new, "true");
}

"true", "No Proxy", "Proxy", "Basic" and "Basic " are reported.

Found in ballerina/http test packages.

Suggested Improvement
  • Don't report "true" and "false", as #109 already does for boolean values.
  • Don't report a value that is only an authentication scheme name (Basic, Bearer, Digest, with or without the trailing space), in the same way as the protocol keywords in #109.
  • Don't treat a name as secret-named when the secret word is qualified by a boolean prefix such as has, is or use (hasAuthHeader).
Version

0.13.0

主要语言
Java
星标
15
派生
12
平均合并
2 天 19 小时
30 天内合并 PR
20

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ballerina-platform/static-code-analysis-tool 的其他 Issue

查看 ballerina-platform/static-code-analysis-tool 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。