Skip to content

How about to support Makefile variable pattern $(VARIABLE) in database-connection-string rule #1190

@pankona

Description

@pankona

Summary

How about to support Makfile variable patter $(VAR) in database-connection-string rule?
This must improve compatibility with Make-based projects.

Basic example

My Makefile includes DB connection information like this:

DB_URL = postgres://$(PGUSER):$(PGPASSWORD)@$(PGHOST)/$(PGDATABASE)

This Makefile is warned by secretlint. It seems such variable string like $(PGPASSWORD) is not included in isVariableLikeString function.

function isVariableLikeString(str: string): boolean {
// Check for common variable patterns with length limits to prevent ReDoS
const variablePatterns = [
/\$\{[^}]{1,50}\}/, // ${var}
/\{\{[^}]{1,50}\}\}/, // {{var}}
/\{[^}]{1,50}\}/, // {var}
/%[A-Z_]{1,30}%/, // %VAR%
/\$[A-Z_]{1,30}/, // $VAR
];

I'm glad if this is allowed as another variables pattern.
Here's example.

function isVariableLikeString(str: string): boolean {
    const variablePatterns = [
        /\$\{[^}]{1,50}\}/, // ${var}
        /\{\{[^}]{1,50}\}\}/, // {{var}}
        /\{[^}]{1,50}\}/, // {var}
        /%[A-Z_]{1,30}%/, // %VAR%
        /\$[A-Z_]{1,30}/, // $VAR
        /\$\([^)]{1,50}\)/, // $(var) - *** Add line like this? ***
    ];

    return variablePatterns.some((pattern) => pattern.test(str));
}

Motivation

  • I think it is common to have database connection strings in a Makefile.
  • Supporting common variable patterns would make secretlint even more useful.
  • Of course, it helps my project, I would be happy, too.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions