Skip to content

Commit

Permalink
chore: prepare split between mysql and pg
Browse files Browse the repository at this point in the history
  • Loading branch information
cfabianski committed Feb 19, 2024
1 parent 27b44eb commit 53727fc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ patterns:
$<SQL>.Config{$<!>Passwd: $<STRING_LITERAL>}
filters:
- variable: SQL
detection: go_lang_hardcoded_database_password_mysql_init
detection: go_lang_hardcoded_mysql_database_password_init
scope: cursor
- variable: STRING_LITERAL
detection: string_literal
Expand All @@ -12,20 +12,20 @@ patterns:
$<INIT>.Open($<_>, $<STRING>)
filters:
- variable: INIT
detection: go_lang_hardcoded_database_password_init
detection: go_lang_hardcoded_mysql_database_password_sql_init
scope: cursor
- variable: STRING
string_regex: \A\w+:.+@.*\z
scope: cursor
auxiliary:
- id: go_lang_hardcoded_database_password_mysql_init
- id: go_lang_hardcoded_mysql_database_password_init
patterns:
- import $<!>"github.com/go-sql-driver/mysql"
- |
import (
$<!>"github.com/go-sql-driver/mysql"
)
- id: go_lang_hardcoded_database_password_init
- id: go_lang_hardcoded_mysql_database_password_sql_init
patterns:
- import $<!>"database/sql"
- |
Expand All @@ -35,7 +35,7 @@ auxiliary:
languages:
- go
metadata:
description: "Usage of hard-coded database password"
description: "Usage of hard-coded MySQL database password"
remediation_message: |
## Description
Expand All @@ -45,5 +45,5 @@ metadata:
- [OWASP hardcoded passwords](https://owasp.org/www-community/vulnerabilities/Use_of_hard-coded_password)
cwe_id:
- 259
id: go_lang_hardcoded_database_password
documentation_url: https://docs.bearer.com/reference/rules/go_lang_hardcoded_database_password
id: go_lang_hardcoded_mysql_database_password
documentation_url: https://docs.bearer.com/reference/rules/go_lang_hardcoded_mysql_database_password
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Use bearer:expected go_lang_hardcoded_database_password to flag expected findings
// Use of bearer:expected go_lang_hardcoded_mysql_database_password to flag expected findings
package main

import (
Expand All @@ -20,7 +20,7 @@ func bad1() {
dsn := fmt.Sprintf("%s:%s@tcp(localhost:%d)/%s?charset=utf8", dbUser, dbPassword, port, dbName)

// Connect to the database
// bearer:expected go_lang_hardcoded_database_password
// bearer:expected go_lang_hardcoded_mysql_database_password
db, err := sql.Open("mysql", dsn)
if err != nil {
panic(err)
Expand All @@ -34,7 +34,7 @@ func bad1() {
func bad1() {
cfg := mysql.Config{
User: "user",
// bearer:expected go_lang_hardcoded_database_password
// bearer:expected go_lang_hardcoded_mysql_database_password
Passwd: "password",
Net: "tcp",
Addr: "127.0.0.1:3306",
Expand Down

0 comments on commit 53727fc

Please sign in to comment.