Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/cfnlint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,10 @@ def _glob_filenames(
all_filenames = []

for filename in filenames:
add_filenames = glob.glob(filename, recursive=True)
if Path(filename).is_file():
add_filenames = [filename]
else:
add_filenames = glob.glob(filename, recursive=True)

if not add_filenames and not self.ignore_bad_template:
if raise_exception:
Expand Down
13 changes: 13 additions & 0 deletions test/unit/module/config/test_config_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import logging
import os
import tempfile
from pathlib import Path
from test.testlib.testcase import BaseTestCase
from unittest.mock import patch
Expand Down Expand Up @@ -199,6 +200,18 @@ def test_config_expand_paths(self, isatty_mock, yaml_mock):
],
)

@patch("cfnlint.config.ConfigFileArgs._read_config", create=True)
def test_config_literal_path_with_glob_characters(self, yaml_mock):
"""Test literal paths containing glob metacharacters."""
yaml_mock.side_effect = [{}, {}]
with tempfile.TemporaryDirectory() as temp_dir:
filename = Path(temp_dir) / "template[1].yaml"
filename.touch()

config = cfnlint.config.ConfigMixIn(templates=[str(filename)])

self.assertEqual(config.templates, [str(filename)])

@patch("cfnlint.config.ConfigFileArgs._read_config", create=True)
@patch("sys.stdin.isatty", return_va=True)
def test_config_expand_paths_nomatch(self, isatty_mock, yaml_mock):
Expand Down