Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
777d06f
test
abadawi591 Aug 7, 2025
cdd92b0
add multi spec detection and analysis for radar
abadawi591 Aug 27, 2025
cc1158c
dev work
abadawi591 Oct 14, 2025
682e47d
fix import
abadawi591 Oct 14, 2025
94b7604
dev
abadawi591 Oct 14, 2025
8446a03
dev
abadawi591 Oct 15, 2025
3662a01
dev
abadawi591 Oct 15, 2025
76f897a
Fix critical bug: swap parameters in detect_patch_file_issues call
abadawi591 Oct 15, 2025
13428c2
Fix GitHub comment posting - use correct method and format
abadawi591 Oct 15, 2025
6939fba
Replace GitHubClient with working 3.0-dev version
abadawi591 Oct 15, 2025
fe613df
Fix GitHub comment posting - use correct method
abadawi591 Oct 15, 2025
2343b11
test
abadawi591 Oct 15, 2025
717c655
test
abadawi591 Oct 15, 2025
bd5fbd6
test
abadawi591 Oct 15, 2025
22aa3d9
Enhance GitHub comment formatting with interactive HTML report
abadawi591 Oct 15, 2025
1c5fcbe
Major enhancements to PR check reporting
abadawi591 Oct 15, 2025
2a4745f
Complete PR check comment formatting improvements
abadawi591 Oct 15, 2025
c1c4f44
Phase 1 & 2: Add delimiters and fix macro expansion
abadawi591 Oct 15, 2025
3c18c7b
Fix HTML report link visibility - make it prominent
abadawi591 Oct 15, 2025
c546113
Remove HTML embedding fallback until Azure Blob Storage is configured
abadawi591 Oct 15, 2025
faf6d0e
Add Azure Blob Storage integration for HTML reports with UMI authenti…
abadawi591 Oct 16, 2025
0fe9af4
Add comprehensive blob storage logging and remove stale checks API code
abadawi591 Oct 16, 2025
42362c9
Add container diagnostics and auto-create with public access
abadawi591 Oct 16, 2025
f812673
Remove container auto-create logic - container configured manually
abadawi591 Oct 16, 2025
47102f8
Update OAuth callback URL to radarfunc endpoint
abadawi591 Oct 21, 2025
52a5b06
Fix GitHub OAuth Client ID mismatch
abadawi591 Oct 21, 2025
78a2647
Add PR owner permission for challenge submissions
abadawi591 Oct 21, 2025
3de6bd8
Prepare for OAuth enhancement: organize docs and add Azure Function f…
abadawi591 Oct 21, 2025
440937a
test: basic anti-pattern detection (curl.spec)
abadawi591 Oct 22, 2025
55ee192
feat: Add challenge/feedback UI and enhanced role badges
abadawi591 Oct 22, 2025
951b9ca
Merge branch 'abadawi/multi-spec-radar' into test/basic-antipatterns
abadawi591 Oct 22, 2025
73cfd51
debug: Add detailed error logging for BlobStorageClient initialization
abadawi591 Oct 22, 2025
268acb8
Merge enhanced BlobStorageClient error logging
abadawi591 Oct 22, 2025
e351174
fix: Configure UMI client ID for blob storage authentication
abadawi591 Oct 22, 2025
1ef61f9
Merge UMI client ID configuration for blob storage
abadawi591 Oct 22, 2025
9a90127
fix: Add UMI configuration for Azure Function and improve HTML link
abadawi591 Oct 22, 2025
8a842a7
fix: Add UMI client ID configuration script for Azure Function
abadawi591 Oct 22, 2025
f73a429
fix: Create analytics.json on first challenge submission
abadawi591 Oct 22, 2025
f876d77
feat: Add GitHub PR comment posting for challenge submissions
abadawi591 Oct 22, 2025
83a4e7b
feat: Implement hybrid approach - GitHub comments + labels
abadawi591 Oct 22, 2025
3977beb
docs: Add manual instructions for creating GitHub labels
abadawi591 Oct 22, 2025
8c8b87e
debug: Enhance error logging for GitHub comment/label posting
abadawi591 Oct 22, 2025
05a7972
Merge debug logging and label simplification
abadawi591 Oct 22, 2025
35d9da8
feat: Add label automation for RADAR feedback workflow
abadawi591 Oct 22, 2025
d5ad711
feat: Add label automation for RADAR feedback workflow
abadawi591 Oct 22, 2025
cc0c065
test: Merge label automation for testing
abadawi591 Oct 22, 2025
94542f6
fix: Properly escape HTML attributes in challenge buttons
abadawi591 Oct 22, 2025
aa4aa75
feat: HTML report link opens in new tab automatically
abadawi591 Oct 22, 2025
45059e4
fix: Remove duplicate html import in challenge button code
abadawi591 Oct 22, 2025
036850e
test: Comprehensive multi-spec antipattern test
abadawi591 Oct 22, 2025
50bc47c
fix: Escape HTML in pattern description display text
abadawi591 Oct 22, 2025
80fa8ad
fix: Escape HTML in pattern description display text
abadawi591 Oct 22, 2025
38eb5c7
Merge branch 'abadawi/multi-spec-radar' into test/multi-spec-antipatt…
abadawi591 Oct 22, 2025
ea197b8
fix: Escape newlines in JavaScript alert messages
abadawi591 Oct 23, 2025
b7507b0
fix: Escape newlines in JavaScript alert messages
abadawi591 Oct 23, 2025
b2e4f5b
Merge branch 'abadawi/multi-spec-radar' into test/multi-spec-antipatt…
abadawi591 Oct 23, 2025
f383c22
feat: Improve error handling for token expiration and GitHub API fail…
abadawi591 Oct 23, 2025
7d172a9
test: Trigger pipeline to generate HTML with diagnostic logging
abadawi591 Oct 23, 2025
d757176
Fix RADAR issues: enhanced diagnostics, PR metadata display, and link…
abadawi591 Oct 23, 2025
4abbdcd
fix: Add PR metadata fetching and correct GitHub token variable
abadawi591 Oct 24, 2025
840bc34
fix: Make HTML report link open in new tab
abadawi591 Oct 24, 2025
8f2e18f
feat: Azure Function now fetches GitHub token from Key Vault
abadawi591 Oct 24, 2025
edcd181
docs: Add Azure Function deployment guide
abadawi591 Oct 24, 2025
b32d110
fix: Use CBL Mariner bot token from Key Vault variable group
abadawi591 Oct 24, 2025
bf39750
fix: Correct YAML syntax in variables section
abadawi591 Oct 24, 2025
afcb33d
fix: Remove variable group reference - use pipeline variables instead
abadawi591 Oct 24, 2025
1b8c1d0
debug: Add logging to diagnose empty GITHUB_TOKEN issue
abadawi591 Oct 24, 2025
f4297dc
feat: Challenge comments posted by user, labels by bot
abadawi591 Oct 24, 2025
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
106 changes: 68 additions & 38 deletions .pipelines/prchecks/CveSpecFilePRCheck/AntiPatternDetector.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,44 +138,72 @@ def detect_all(self, file_path: str, file_content: str,
logger.info(f"Found {len(all_patterns)} anti-patterns in {file_path}")
return all_patterns

def detect_patch_file_issues(self, file_path: str, file_content: str,
file_list: List[str]) -> List[AntiPattern]:
def detect_patch_file_issues(self, spec_content: str, file_path: str, file_list: List[str]) -> List[AntiPattern]:
"""
Detect issues related to patch files.
Detect issues related to patch files in spec files.

This function validates patch file references in spec files against the actual
files present in the package directory. It performs bidirectional validation
to ensure consistency between spec declarations and filesystem state.

Issues detected:
----------------
1. Missing patch files (ERROR):
- Patches referenced in spec but not found in directory
- Example: Patch0: security.patch (but file doesn't exist)

2. Unused patch files (WARNING):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historically this has actually been the issue that caused us the most grief. If a patch is in the .spec file we get a build error, but it silently continues with the .spec file is missing the patch macro. I would mark this as an error rather than warning.

Maybe if there are multiple .spec files, its a warning if at least one uses the patch?

- .patch files in directory but not referenced in spec
- Example: old-fix.patch exists but no Patch line references it

3. CVE patch mismatches (ERROR):
- CVE-named patches without corresponding CVE documentation in spec
- Example: CVE-2023-1234.patch exists but CVE-2023-1234 not in changelog

Args:
file_path: Path to the spec file relative to repo root
file_content: Content of the spec file
file_list: List of files in the same directory
spec_content: Full text content of the spec file
file_path: Path to the spec file being analyzed
file_list: List of all files in the package directory

Returns:
List of detected patch-related anti-patterns
List of AntiPattern objects representing detected issues
"""
patterns = []

# Extract patch references from spec file
# Extract patch references from spec file with line numbers
# Updated regex to handle both simple filenames and full URLs
patch_regex = r'^Patch(\d+):\s+(.+?)$'
patch_refs = {}
pattern = r'^Patch(\d+):\s+(.+?)$'

for line_num, line in enumerate(file_content.splitlines(), 1):
match = re.match(pattern, line.strip())
for line_num, line in enumerate(spec_content.split('\n'), 1):
match = re.match(patch_regex, line.strip())
if match:
patch_num = match.group(1)
patch_file = match.group(2).strip()
patch_refs[patch_file] = line_num

# Check if referenced patch file exists
if patch_file not in file_list:
patterns.append(AntiPattern(
id='missing-patch-file',
name="Missing Patch File",
description=f"Patch file '{patch_file}' is referenced in the spec but not found in the directory",
severity=self.severity_map.get('missing-patch-file', Severity.ERROR),
file_path=file_path,
line_number=line_num,
context=line.strip(),
recommendation="Add the missing patch file or update the Patch reference"
))
# Extract just the filename from URL if it's a full path
# Handle URLs like https://www.linuxfromscratch.org/patches/downloads/glibc/glibc-2.38-fhs-1.patch
if '://' in patch_file:
# Extract filename from URL (last part after the final /)
patch_file = patch_file.split('/')[-1]
elif '/' in patch_file:
# Handle relative paths like patches/fix.patch
patch_file = patch_file.split('/')[-1]

patch_refs[patch_file] = (line_num, line.strip())

# Check for missing patch files (referenced in spec but not in directory)
for patch_file, (line_num, line_content) in patch_refs.items():
if patch_file not in file_list:
patterns.append(AntiPattern(
id='missing-patch-file',
name="Missing Patch File",
description=f"Patch file '{patch_file}' referenced in spec but not found in directory",
severity=self.severity_map.get('missing-patch-file', Severity.ERROR),
file_path=file_path,
line_number=line_num,
context=line_content,
recommendation="Add the missing patch file or update the Patch reference"
))

# Check for CVE patch naming conventions
for patch_file in file_list:
Expand All @@ -193,20 +221,22 @@ def detect_patch_file_issues(self, file_path: str, file_content: str,
recommendation="Add a reference to the patch file or remove it if not needed"
))

# Check if CVE patches match CVE references
# Check for CVE-named patches
if patch_file.startswith('CVE-'):
cve_id = re.match(r'(CVE-\d{4}-\d+)', patch_file)
if cve_id and cve_id.group(1) not in file_content:
patterns.append(AntiPattern(
id='cve-patch-mismatch',
name="CVE Patch Mismatch",
description=f"Patch file '{patch_file}' appears to fix {cve_id.group(1)} but this CVE is not mentioned in the spec",
severity=self.severity_map.get('cve-patch-mismatch', Severity.ERROR),
file_path=file_path,
line_number=None,
context=None,
recommendation=f"Add {cve_id.group(1)} to the spec file changelog entry"
))
cve_match = re.search(r'(CVE-\d{4}-\d+)', patch_file)
if cve_match:
cve_id = cve_match.group(1)
if cve_id not in spec_content:
patterns.append(AntiPattern(
id='cve-patch-mismatch',
name="CVE Patch Mismatch",
description=f"Patch file '{patch_file}' contains CVE reference but {cve_id} is not mentioned in spec",
severity=self.severity_map.get('cve-patch-mismatch', Severity.ERROR),
file_path=file_path,
line_number=None,
context=None,
recommendation=f"Add {cve_id} to the spec file changelog entry"
))

return patterns

Expand Down
Loading
Loading