Skip to content

Commit 7635602

Browse files
Copilotfelickz
andcommitted
Replace link checker script with custom agent instructions
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
1 parent 84ced37 commit 7635602

File tree

7 files changed

+96
-508
lines changed

7 files changed

+96
-508
lines changed

.github/agents/link-checker.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Link Checker Agent
2+
3+
This custom agent validates all HTTP/HTTPS links in the repository's markdown files to ensure they are functional and do not return 404 errors or broken responses.
4+
5+
## Agent Description
6+
7+
You are a link validation specialist. Your task is to check all links in markdown files to ensure they are accessible and functional.
8+
9+
## Instructions
10+
11+
When invoked to check links in this repository:
12+
13+
1. **Scan markdown files**: Use `grep` or `glob` to find all `.md` files in the repository.
14+
15+
2. **Extract links**: From each markdown file, extract all HTTP and HTTPS URLs using pattern matching:
16+
- Markdown links: `[text](url)`
17+
- Plain URLs: `https?://...`
18+
19+
3. **Validate links**: For each unique URL:
20+
- Use `curl -I -L --max-time 10` to check the HTTP status
21+
- Skip relative links (e.g., `README.md`, `#anchors`) as they are valid markdown
22+
- Track the following:
23+
- ✅ Working links (HTTP 200-299)
24+
- ❌ Broken links (HTTP 404)
25+
- ⚠️ Errors (connection failures, timeouts)
26+
- ↪️ Redirects (HTTP 301, 302, 307, 308)
27+
28+
4. **Report findings**:
29+
- Summarize total links checked
30+
- List all broken links (404s) with:
31+
- File name and line number
32+
- URL
33+
- HTTP status code
34+
- List any connection errors separately (may be due to network restrictions)
35+
- Provide recommendations for fixing broken links
36+
37+
5. **Fix broken links**:
38+
- For 404 errors, determine if:
39+
- Repository/resource has moved (find new URL)
40+
- Repository/resource no longer exists (remove link)
41+
- URL format has changed (update URL)
42+
- Update the markdown files to fix broken links
43+
- Verify fixes by re-checking the updated URLs
44+
45+
## Examples
46+
47+
### Checking Links
48+
```bash
49+
# Find all markdown files
50+
find . -name "*.md" -not -path "./.git/*"
51+
52+
# Extract and check a URL
53+
curl -I -L --max-time 10 https://example.com/page
54+
```
55+
56+
### Common Issues
57+
58+
- **404 Not Found**: Repository or page doesn't exist
59+
- Action: Remove link or find the new location
60+
61+
- **301/302 Redirects**: URL has moved permanently/temporarily
62+
- Action: Update to the final destination URL if permanent
63+
64+
- **Connection Errors**: DNS failure, timeout, network restrictions
65+
- Action: May be environmental; verify manually if possible
66+
67+
## Output Format
68+
69+
Provide a concise report:
70+
71+
```
72+
Link Check Results
73+
==================
74+
75+
✅ Working: X links
76+
❌ Broken: Y links
77+
⚠️ Errors: Z links
78+
79+
Broken Links (404):
80+
1. README.md:42 - https://example.com/old-page (404 Not Found)
81+
2. SECURITY.md:15 - https://example.com/moved (404 Not Found)
82+
83+
Recommendations:
84+
- Line 42: Remove or update to new URL
85+
- Line 15: Updated in latest commit
86+
```
87+
88+
## Notes
89+
90+
- Focus only on HTTP/HTTPS links; skip `mailto:`, `ftp:`, and other schemes
91+
- Relative markdown links (e.g., `[Guide](CONTRIBUTING.md)`) are valid and should be skipped
92+
- Some domains may be blocked in restricted environments; connection errors don't always mean broken links
93+
- Prioritize fixing genuine 404 errors over connection errors

.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

LINK_CHECKER_README.md

Lines changed: 0 additions & 99 deletions
This file was deleted.

LINK_CHECK_REPORT.md

Lines changed: 0 additions & 84 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Everything you need to install, run, and view CodeQL results locally or in conta
8888
### CodeQL AI & LLM Tooling
8989
- [GitHubSecurityLab/seclab-taskflow-agent](https://github.com/GitHubSecurityLab/seclab-taskflow-agent) - The GitHub Security Lab Taskflow Agent is an MCP enabled multi-Agent framework. See the [CVE-2023-2283](https://github.com/GitHubSecurityLab/seclab-taskflow-agent/blob/main/examples/taskflows/CVE-2023-2283.yaml) taskflow for an example of how to have an Agent review C code using a CodeQL database ([demo video](https://www.youtube.com/watch?v=eRSPSVW8RMo)).
9090
- [GitHubSecurityLab/seclab-taskflows](https://github.com/GitHubSecurityLab/seclab-taskflows) - Example taskflows to use with the GitHub Security Lab Taskflow Agent Framework. Intended to be an easy-to-copy template for anybody who would like to publish their own suite of taskflows.
91+
- [github/codeql-development-mcp-server](https://github.com/github/codeql-development-mcp-server) - GitHub CodeQL Development MCP Server supporting LLM requests for CodeQL development tools and resources.
9192
- [advanced-security/codeql-development-template](https://github.com/advanced-security/codeql-development-template) - Copilot-native repository template for CodeQL query development. Lowering the barrier to entry for CodeQL development through natural language and GitHub Copilot. A GitHub repository template for building custom CodeQL queries with AI assistance. This template provides a structured environment with prompts, instructions, and workflows designed to guide GitHub Copilot Coding Agent through the complete CodeQL development lifecycle.
9293
- [JordyZomer/codeql-mcp](https://github.com/JordyZomer/codeql-mcp) - This project runs a Model Context Protocol (MCP) server that wraps the CodeQL query server. It enables tools like Cursor or AI agents to interact with CodeQL through structured commands and doc search.
9394

@@ -152,6 +153,7 @@ Resources for extending CodeQL, creating packs, and using custom queries.
152153
### Custom Modeling
153154
- [advanced-security/codeql-summarize](https://github.com/advanced-security/codeql-summarize) - CodeQL Summary Generator to generate Models as Data (MaD) from CodeQL databases.
154155
- [GitHubSecurityLab/CodeQL-Community-Packs](https://github.com/GitHubSecurityLab/CodeQL-Community-Packs/blob/main/configs/default.yml#L19-L25) - GitHub Security Lab model packs
156+
- [octodemo/vulnerable-pickle-app](https://github.com/octodemo/vulnerable-pickle-app/blob/main/custom-queries/python/dangerous-functions.ql) - Ex: Python Pickle - mapping a custom framework in python
155157

156158
### CodeQL Queries/Bundles
157159

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ This information will help us triage your report more quickly.
2828

2929
## Policy
3030

31-
See [GitHub's Safe Harbor Policy](https://docs.github.com/en/site-policy/security-policies/github-bug-bounty-program-legal-safe-harbor)
31+
See [GitHub's Safe Harbor Policy](https://docs.github.com/en/github/site-policy/github-bug-bounty-program-legal-safe-harbor#1-safe-harbor-terms)

0 commit comments

Comments
 (0)