Skip to content

Commit 2085cce

Browse files
authored
Merge pull request #298 from github/codeql-polynomial-regex
CodeQL - Limit polynomial regex to only match 1000 characters at most
2 parents 0127026 + dd2af63 commit 2085cce

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/octocatalog-diff/catalog-util/command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def setup
9191
facts_terminus = @options.fetch(:facts_terminus, 'yaml')
9292
if facts_terminus == 'yaml'
9393
cmdline << "--factpath=#{Shellwords.escape(File.join(@compilation_dir, 'var', 'yaml', 'facts'))}"
94-
if @options[:fact_file].is_a?(String) && @options[:fact_file] =~ /.*\.(\w+)$/
94+
if @options[:fact_file].is_a?(String) && @options[:fact_file] =~ /.*{1,1000}\.(\w+)$/
9595
fact_file = File.join(@compilation_dir, 'var', 'yaml', 'facts', "#{@node}.#{Regexp.last_match(1)}")
9696
FileUtils.cp @options[:fact_file], fact_file unless File.file?(fact_file) || @options[:fact_file] == fact_file
9797
end

spec/octocatalog-diff/tests/util/parallel_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ def two(arg, _logger = nil)
343343
expect(two_result.exception).to eq(nil)
344344
expect(two_result.output).to match(/^two def \d+$/)
345345

346-
one_time = Regexp.last_match(1).to_i if one_result.output =~ /(\d+)$/
347-
two_time = Regexp.last_match(1).to_i if two_result.output =~ /(\d+)$/
346+
one_time = Regexp.last_match(1).to_i if one_result.output =~ /(\d+{1,1000})$/
347+
two_time = Regexp.last_match(1).to_i if two_result.output =~ /(\d+{1,1000})$/
348348
expect(one_time).to be < two_time
349349
end
350350

0 commit comments

Comments
 (0)