Implement fast bazel target lookup with index caching by titusfortner · Pull Request #16974 · SeleniumHQ/selenium
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
| Security Compliance | |
| ⚪ | Shell command injectionDescription: The Referred Codetask :affected_targets, %i[commit_range index_file] do |_task, args| range = args[:commit_range] || 'HEAD' index_file = args[:index_file] || 'build/bazel-test-target-index.json' base_rev, head_rev = if range.include?('..') range.split('..', 2) else ["#{range}^", range] end puts "Commit range: #{base_rev}..#{head_rev}" changed_files = `git diff --name-only #{base_rev} #{head_rev}`.split("\n").map(&:strip).reject(&:empty?) |
Bazel query injectionDescription: Bazel query strings are constructed by interpolating the repository file path (via Referred Codequery = test_files.filter_map { |f|
pkg = find_bazel_package(f)
next if pkg.nil?
# Bazel srcs often use paths relative to the package, not basenames.
rel = f.sub(%r{\A#{Regexp.escape(pkg)}/}, '')
"attr(srcs, '#{rel}', //#{pkg}:*)"
}.join(' + ')
return [] if query.empty?
targets = []
Bazel.execute('query', ['--output=label'], query) do |out|
targets = out.lines.map(&:strip).select { |l| l.start_with?('//') }
end | |
Cache path traversalDescription: The workflow uses Referred Code- name: Restore cache if: inputs.cache-name != '' uses: actions/cache/restore@v4 with: path: ${{ inputs.cache-name }}.gz key: ${{ inputs.cache-name }}- restore-keys: ${{ inputs.cache-name }}- | |
| Ticket Compliance | |
| ⚪ | 🎫 No ticket provided
|
| Codebase Duplication Compliance | |
| ⚪ | Codebase context is not definedFollow the guide to enable codebase context checks. |
| Custom Compliance | |
| 🟢 |
Generic: Comprehensive Audit TrailsObjective: To create a detailed and reliable record of critical system actions for security analysis Status: Passed
|
Generic: Meaningful Naming and Self-Documenting CodeObjective: Ensure all identifiers clearly express their purpose and intent, making code Status: Passed
| |
Generic: Secure Error HandlingObjective: To prevent the leakage of sensitive system information through error messages while Status: Passed
| |
| 🔴 | Generic: Robust Error Handling and Edge Case ManagementObjective: Ensure comprehensive error handling that provides meaningful context and graceful Status: Referred Codetask :affected_targets, %i[commit_range index_file] do |_task, args| range = args[:commit_range] || 'HEAD' index_file = args[:index_file] || 'build/bazel-test-target-index.json' base_rev, head_rev = if range.include?('..') range.split('..', 2) else ["#{range}^", range] end puts "Commit range: #{base_rev}..#{head_rev}" changed_files = `git diff --name-only #{base_rev} #{head_rev}`.split("\n").map(&:strip).reject(&:empty?) puts "Changed files: #{changed_files.size}" targets = if index_file && File.exist?(index_file) affected_targets_with_index(changed_files, index_file) else puts 'No index found, using directory-based fallback' affected_targets_fallback(changed_files) end ... (clipped 130 lines)
|
Generic: Security-First Input Validation and Data HandlingObjective: Ensure all data inputs are validated, sanitized, and handled securely to prevent Status: Referred Codetask :affected_targets, %i[commit_range index_file] do |_task, args| range = args[:commit_range] || 'HEAD' index_file = args[:index_file] || 'build/bazel-test-target-index.json' base_rev, head_rev = if range.include?('..') range.split('..', 2) else ["#{range}^", range] end puts "Commit range: #{base_rev}..#{head_rev}" changed_files = `git diff --name-only #{base_rev} #{head_rev}`.split("\n").map(&:strip).reject(&:empty?) puts "Changed files: #{changed_files.size}"
| |
| ⚪ | Generic: Secure Logging PracticesObjective: To ensure logs are useful for debugging and auditing without exposing sensitive Status: Referred Code puts "Commit range: #{base_rev}..#{head_rev}"
changed_files = `git diff --name-only #{base_rev} #{head_rev}`.split("\n").map(&:strip).reject(&:empty?)
puts "Changed files: #{changed_files.size}"
targets = if index_file && File.exist?(index_file)
affected_targets_with_index(changed_files, index_file)
else
puts 'No index found, using directory-based fallback'
affected_targets_fallback(changed_files)
end
if targets.empty?
puts 'No test targets affected'
File.write('bazel-targets.txt', '')
else
puts "Found #{targets.size} affected test targets"
File.write('bazel-targets.txt', targets.sort.join(' '))
targets.sort.each { |t| puts t }
end
end
... (clipped 42 lines)
|
| |
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label