Skip to content

Commit b6bad4a

Browse files
committed
Code Securty QL
1 parent 03c5efd commit b6bad4a

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

.github/codeql/queries/FindHardcodedSecrets.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ predicate isSecretValue(string value) {
1919
}
2020

2121
from Field f, Expr::Literal lit
22+
from Field f, StringLiteral lit
2223
where
2324
isSecretField(f) and
24-
lit.getType().hasName("string") and
2525
f.getInitializer() = lit and
2626
isSecretValue(lit.getValue())
2727
select lit, "Hardcoded secret detected: '" + lit.getValue() + "' assigned to field '" + f.getName() + "'"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ paths-ignore:
478478
> - Target fields that are initialized with string literals.
479479
> - Match field names containing `apiKey`, `token`, `secret`, `password`, or `auth` (case-insensitive).
480480
> - Match values that resemble secrets, such as those starting with `sk_`, `token_`, `apikey_`, or 32+ base64-like characters.
481-
> - Use `Field` and `string_literal` from the `csharp` CodeQL library.
481+
> - Use `Field` and `Literal` from the `csharp` CodeQL library.
482482
> - Return the matched string literal and a message indicating a hardcoded secret.
483483
> - Include standard CodeQL metadata: `@name`, `@description`, `@id`, `@tags`, `@problem.severity`, and `@security-severity`.
484484

@@ -506,9 +506,9 @@ predicate isSecretValue(string value) {
506506
}
507507
508508
from Field f, Expr::Literal lit
509+
from Field f, StringLiteral lit
509510
where
510511
isSecretField(f) and
511-
lit.getType().hasName("string") and
512512
f.getInitializer() = lit and
513513
isSecretValue(lit.getValue())
514514
select lit, "Hardcoded secret detected: '" + lit.getValue() + "' assigned to field '" + f.getName() + "'"

0 commit comments

Comments
 (0)