@@ -133,40 +133,25 @@ def create_sbom_output(self, diff: Diff) -> dict:
133133 @staticmethod
134134 def expand_brace_pattern (pattern : str ) -> List [str ]:
135135 """
136- Recursively expands brace expressions (e.g., {a,b,c}) into separate patterns, supporting nested braces.
137- """
138- def recursive_expand (pat : str ) -> List [str ]:
139- stack = []
140- for i , c in enumerate (pat ):
141- if c == '{' :
142- stack .append (i )
143- elif c == '}' and stack :
144- start = stack .pop ()
145- if not stack :
146- # Found the outermost pair
147- before = pat [:start ]
148- after = pat [i + 1 :]
149- inner = pat [start + 1 :i ]
150- # Split on commas not inside nested braces
151- options = []
152- depth = 0
153- last = 0
154- for j , ch in enumerate (inner ):
155- if ch == '{' :
156- depth += 1
157- elif ch == '}' :
158- depth -= 1
159- elif ch == ',' and depth == 0 :
160- options .append (inner [last :j ])
161- last = j + 1
162- options .append (inner [last :])
163- results = []
164- for opt in options :
165- expanded = before + opt + after
166- results .extend (recursive_expand (expanded ))
167- return results
168- return [pat ]
169- return recursive_expand (pattern )
136+ Expands brace expressions (e.g., {a,b,c}) into separate patterns.
137+ """
138+ brace_regex = re .compile (r"\{([^{}]+)\}" )
139+
140+ # Expand all brace groups
141+ expanded_patterns = [pattern ]
142+ while any ("{" in p for p in expanded_patterns ):
143+ new_patterns = []
144+ for pat in expanded_patterns :
145+ match = brace_regex .search (pat )
146+ if match :
147+ options = match .group (1 ).split ("," ) # Extract values inside {}
148+ prefix , suffix = pat [:match .start ()], pat [match .end ():]
149+ new_patterns .extend ([prefix + opt + suffix for opt in options ])
150+ else :
151+ new_patterns .append (pat )
152+ expanded_patterns = new_patterns
153+
154+ return expanded_patterns
170155
171156 @staticmethod
172157 def is_excluded (file_path : str , excluded_dirs : Set [str ]) -> bool :
@@ -191,7 +176,13 @@ def find_files(self, path: str) -> List[str]:
191176 files : Set [str ] = set ()
192177
193178 # Get supported patterns from the API
194- patterns = self .get_supported_patterns ()
179+ try :
180+ patterns = self .get_supported_patterns ()
181+ except Exception as e :
182+ log .error (f"Error getting supported patterns from API: { e } " )
183+ log .warning ("Falling back to local patterns" )
184+ from .utils import socket_globs as fallback_patterns
185+ patterns = fallback_patterns
195186
196187 for ecosystem in patterns :
197188 if ecosystem in self .config .excluded_ecosystems :
0 commit comments