Skip to content

Commit 1d75bfb

Browse files
committed
Address latest PR review comments
1 parent 0d3f529 commit 1d75bfb

13 files changed

Lines changed: 98 additions & 69 deletions
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
applyTo: 'server/src/resources/**/*.md'
3+
description: 'Instructions for MCP server resource markdown files served to LLMs.'
4+
---
5+
6+
# Copilot Instructions for `server/src/resources/**/*.md` resource files
7+
8+
## PURPOSE
9+
10+
This file contains instructions for working with markdown resource files in the `server/src/resources/` directory. These files are imported at build time (via esbuild's `.md: 'text'` loader) and served to LLMs through MCP resource endpoints (e.g., `codeql://server/overview`, `codeql://languages/go/ast`). Because LLMs consume these files as authoritative reference material, correctness and consistency are critical.
11+
12+
## REQUIREMENTS
13+
14+
- ALWAYS name resource files to match their MCP endpoint path. For example, a resource served at `codeql://server/overview` must be named `server-overview.md`, and a resource at `codeql://languages/go/ast` must be `languages/go_ast.md`.
15+
- ALWAYS start each resource file with a `#`-level (H1) heading that identifies the resource topic and scope.
16+
- ALWAYS use the v2 module-based DataFlow/TaintTracking API (`module MyConfig implements DataFlow::ConfigSig` with `TaintTracking::Global<MyConfig>`) in all CodeQL code examples. NEVER use the deprecated v1 class-based API (`class MyConfig extends TaintTracking::Configuration` with `override predicate`).
17+
- ALWAYS use `codeql-pack.yml` (not `qlpack.yml`) as the pack configuration filename in all code examples and references.
18+
- ALWAYS ensure any new resource file has a corresponding import and registration in `server/src/types/language-types.ts` (for language-specific resources) or `server/src/lib/resources.ts` (for general resources), and that the test expectations in `server/test/src/resources/` are updated accordingly.
19+
- ALWAYS verify ASCII art diagrams have consistent box corners and formatting.
20+
- ALWAYS ensure code examples are syntactically correct — class names, constructor names, and predicate names must all match (e.g., a class named `FooAsSink` must have a constructor named `FooAsSink()`).
21+
- **ALWAYS run `npm run build-and-test` from the repo root directory and ensure it passes completely before committing any changes.**
22+
23+
## PREFERENCES
24+
25+
- PREFER actionable, tool-oriented content that tells an LLM exactly which MCP tools and prompts to invoke and in what order, over abstract descriptions.
26+
- PREFER concrete code examples over prose explanations for CodeQL patterns and idioms.
27+
- PREFER a single authoritative location for each piece of documentation — if content exists in a resource file, repo-level docs should reference it rather than restate it.
28+
29+
## DOCUMENTATION RELATIONSHIP: `server/src/resources/``docs/ql-mcp/`
30+
31+
The `server/src/resources/server-*.md` files are the **authoritative source** for MCP server tools, prompts, and queries documentation. The `docs/ql-mcp/*.md` files are **thin wrappers** that link to these authoritative sources.
32+
33+
### When to update which file
34+
35+
| Change type | Update `server/src/resources/server-*.md` | Update `docs/ql-mcp/*.md` |
36+
| -------------------------------------------- | ----------------------------------------- | -------------------------------------- |
37+
| Add, remove, or modify an MCP tool | YES — `server-tools.md` | Only if monitoring tools table changes |
38+
| Add, remove, or modify an MCP prompt | YES — `server-prompts.md` | NO — wrapper links to resource file |
39+
| Add or remove a language resource | YES — registration in source code | YES — update language table |
40+
| Add or remove a static resource | YES — resource file + registration | YES — update static resources table |
41+
| Change a resource URI or endpoint path | YES — rename file to match new path | YES — update URI references |
42+
| Fix a typo or improve wording in tool/prompt | YES — resource file only | NO — wrapper inherits the fix |
43+
44+
### Rules
45+
46+
- ALWAYS update the authoritative `server/src/resources/server-*.md` file first, then verify the `docs/ql-mcp/*.md` wrapper still links correctly.
47+
- ALWAYS keep `docs/ql-mcp/*.md` as thin wrappers — they should contain only a brief overview, a link to the authoritative resource file, and any content that is NOT served via MCP (e.g., the optional monitoring tools table in `docs/ql-mcp/tools.md`).
48+
- NEVER duplicate detailed tool, prompt, or resource descriptions in both `server/src/resources/` and `docs/ql-mcp/`. The `docs/ql-mcp/` file must defer to the resource file for all MCP-served content.
49+
50+
## CONSTRAINTS
51+
52+
- NEVER leave any trailing whitespace on any line.
53+
- NEVER include placeholder or TODO content in resource files — if a resource is not ready, exclude it from registration until the content is complete.
54+
- NEVER reference deprecated or removed MCP tools in resource files. When a tool is deprecated, remove all mentions from resource files.
55+
- NEVER mix deprecated and current API patterns in code examples within the same file or across files in this directory.

docs/ql-mcp/resources.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Each supported language can expose one or more of the following resource types u
3232
| java || | |
3333
| javascript ||| |
3434
| python ||| |
35-
| ql || | |
3635
| ruby || | |
3736

3837
### Resource Types

server/dist/codeql-development-mcp-server.js

Lines changed: 6 additions & 13 deletions
Large diffs are not rendered by default.

server/dist/codeql-development-mcp-server.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/src/resources/languages/actions_ast.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# CodeQL AST nodes for `actions` language
2+
13
## CodeQL's core AST classes for `actions` language
24

35
Based on analysis of CodeQL's Actions AST test results from local test files, here are the core AST classes for GitHub Actions analysis:

server/src/resources/languages/csharp_security_query_guide.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,22 +205,20 @@ class EncodingMethod extends MethodCall {
205205

206206
```ql
207207
// Configuration for inappropriate encoding detection
208-
private class InappropriateEncodingConfiguration extends TaintTracking::Configuration {
209-
InappropriateEncodingConfiguration() { this = "InappropriateEncodingConfiguration" }
210-
211-
override predicate isSource(DataFlow::Node source) {
208+
module InappropriateEncodingConfig implements DataFlow::ConfigSig {
209+
predicate isSource(DataFlow::Node source) {
212210
// Encoded values that might be inappropriate for their context
213211
source.asExpr() instanceof EncodingMethod
214212
}
215213
216-
override predicate isSink(DataFlow::Node sink) {
214+
predicate isSink(DataFlow::Node sink) {
217215
// Sinks that require specific encoding types
218216
sink instanceof SqlCommandSink or
219217
sink instanceof HtmlOutputSink or
220218
sink instanceof UrlRedirectSink
221219
}
222220
223-
override predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) {
221+
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
224222
// String concatenation and formatting preserve taint
225223
exists(AddExpr add |
226224
add.getAnOperand() = node1.asExpr() and
@@ -235,6 +233,8 @@ private class InappropriateEncodingConfiguration extends TaintTracking::Configur
235233
)
236234
}
237235
}
236+
237+
module InappropriateEncodingFlow = TaintTracking::Global<InappropriateEncodingConfig>;
238238
```
239239

240240
## Security Query Implementation Guide

server/src/resources/languages/go_library_modeling.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ extensions:
379379
Create a CodeQL model pack to group and distribute YAML files:
380380

381381
```yaml
382-
# qlpack.yml
382+
# codeql-pack.yml
383383
name: my-org/go-security-models
384384
version: 1.0.0
385385
dependencies:
@@ -391,7 +391,7 @@ dataExtensions: '*.yml'
391391

392392
```
393393
my-go-models/
394-
├── qlpack.yml
394+
├── codeql-pack.yml
395395
├── http-frameworks.yml
396396
├── database-orms.yml
397397
└── json-libraries.yml
@@ -406,7 +406,7 @@ codeql pack publish
406406
### Consuming Model Packs
407407

408408
```yaml
409-
# In consumer's qlpack.yml
409+
# In consumer's codeql-pack.yml
410410
dependencies:
411411
my-org/go-security-models: '^1.0.0'
412412
```

server/src/resources/languages/javascript_security_query_guide.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ module VulnerabilityName {
179179
private class RemoteFlowSourceAsSource extends Source instanceof RemoteFlowSource { }
180180
181181
// Define specific sinks based on vulnerability type
182-
private class SpecificSinkAssink extends Sink {
183-
SpecificSinkAsink() {
182+
private class SpecificSinkAsSink extends Sink {
183+
SpecificSinkAsSink() {
184184
// Define sink patterns here
185185
}
186186
}
@@ -267,14 +267,12 @@ select sink.getNode(), source, sink, "[Alert message with $@ placeholder]",
267267
**SSRF Detection Pattern:**
268268

269269
```ql
270-
private class RequestForgeryConfiguration extends TaintTracking::Configuration {
271-
RequestForgeryConfiguration() { this = "RequestForgeryConfiguration" }
272-
273-
override predicate isSource(DataFlow::Node source) {
270+
module RequestForgeryConfig implements DataFlow::ConfigSig {
271+
predicate isSource(DataFlow::Node source) {
274272
source instanceof RemoteFlowSource
275273
}
276274
277-
override predicate isSink(DataFlow::Node sink) {
275+
predicate isSink(DataFlow::Node sink) {
278276
// HTTP client requests where URL is controllable
279277
exists(DataFlow::CallNode call |
280278
call = DataFlow::moduleImport("axios").getAMemberCall(["get", "post", "put", "delete"]) and
@@ -290,19 +288,19 @@ private class RequestForgeryConfiguration extends TaintTracking::Configuration {
290288
)
291289
}
292290
}
291+
292+
module RequestForgeryFlow = TaintTracking::Global<RequestForgeryConfig>;
293293
```
294294

295295
**XSS Detection Pattern:**
296296

297297
```ql
298-
private class ReflectedXssConfiguration extends TaintTracking::Configuration {
299-
ReflectedXssConfiguration() { this = "ReflectedXssConfiguration" }
300-
301-
override predicate isSource(DataFlow::Node source) {
298+
module ReflectedXssConfig implements DataFlow::ConfigSig {
299+
predicate isSource(DataFlow::Node source) {
302300
source instanceof RemoteFlowSource
303301
}
304302
305-
override predicate isSink(DataFlow::Node sink) {
303+
predicate isSink(DataFlow::Node sink) {
306304
// DOM manipulation sinks
307305
exists(DataFlow::PropWrite pw |
308306
pw.getPropertyName() in ["innerHTML", "outerHTML"] and
@@ -315,6 +313,8 @@ private class ReflectedXssConfiguration extends TaintTracking::Configuration {
315313
)
316314
}
317315
}
316+
317+
module ReflectedXssFlow = TaintTracking::Global<ReflectedXssConfig>;
318318
```
319319

320320
## Testing Patterns

server/src/resources/languages/ql_ast.md

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

server/src/resources/performance-patterns.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ The `profile_codeql_query_from_logs` tool is the primary means of evaluating the
1414
4. **Identify bottlenecks**: Review the profile output for predicates with high evaluation times or unexpectedly large result sets.
1515
5. **Refine**: Modify the query to address identified bottlenecks, then re-run and re-profile to verify improvements.
1616

17-
Alternatively, use `profile_codeql_query` to profile a query by running it against a specific database and analyzing the resulting evaluator log in a single step.
18-
1917
### What the Profile Shows
2018

2119
- **Predicate evaluation times** — which predicates are the most expensive
@@ -83,14 +81,13 @@ For monorepos with multiple independent applications separated by process/networ
8381

8482
## Related Tools and Prompts
8583

86-
| Tool / Prompt | Purpose |
87-
| ------------------------------------------------ | -------------------------------------------------------------------- |
88-
| `profile_codeql_query` | Profile a query run against a database (runs the query and profiles) |
89-
| `profile_codeql_query_from_logs` | Profile from existing evaluator logs (no re-run needed) |
90-
| `codeql_generate_log-summary` | Generate a human-readable evaluator log summary |
91-
| `codeql_query_run` | Execute a query (set `evaluationOutput` to capture logs) |
92-
| `explain_codeql_query` prompt | Understand query evaluation flow with Mermaid diagrams |
93-
| `run_query_and_summarize_false_positives` prompt | Assess result quality (precision) |
84+
| Tool / Prompt | Purpose |
85+
| ------------------------------------------------ | -------------------------------------------------------- |
86+
| `profile_codeql_query_from_logs` | Profile from existing evaluator logs (no re-run needed) |
87+
| `codeql_generate_log-summary` | Generate a human-readable evaluator log summary |
88+
| `codeql_query_run` | Execute a query (set `evaluationOutput` to capture logs) |
89+
| `explain_codeql_query` prompt | Understand query evaluation flow with Mermaid diagrams |
90+
| `run_query_and_summarize_false_positives` prompt | Assess result quality (precision) |
9491

9592
## Related Resources
9693

0 commit comments

Comments
 (0)