-
Notifications
You must be signed in to change notification settings - Fork 141
Add configurable file type restrictions to cache-memory and repo-memory with validation failure reporting #15195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
The list of allowed file extensions should be configurable through |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implemented in commit 50c701e. The tools:
cache-memory:
allowed-extensions: [".txt", ".csv", ".json"]
repo-memory:
allowed-extensions: [".md", ".json", ".toml"]When not specified, defaults to
|
…assing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
pkg/workflow/cache.go
Outdated
|
|
||
| // Validate cache-memory file types step | ||
| var validateStep strings.Builder | ||
| fmt.Fprintf(&validateStep, " - name: Validate cache-memory file types (%s)\n", cache.ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot use helper to code generate actions/github-script code
pkg/workflow/cache.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot refactor this template template in a .md and render it
pkg/workflow/cache.go
Outdated
| } else { | ||
| fmt.Fprintf(builder, " - name: Validate cache-memory file types (%s)\n", cache.ID) | ||
| } | ||
| builder.WriteString(" if: always()\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot use helper to generate call to actions/github-script
🔍 PR Triage ResultsCategory: feature (security) | Risk: medium | Priority: 57/100 Scores Breakdown
📋 Recommended Action: batch_reviewMedium risk, medium priority (57/100), good quality. Not auto-mergeable due to pending CI and medium risk level. Should be reviewed but not urgent. Could be batched with other memory/security features if they exist. Batch Info: Eligible for batch-memory-security-001 (monitor for similar PRs) Triaged by PR Triage Agent on 2026-02-12T18:26:00Z (Run #21959060330)
|
|
@copilot keep working |
…cache prompts Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot add allowed-repos: ["github/gh-aw"] on smoke-copilot add-comment |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
✅ Changeset Generator completed successfully! |
|
🧪 Smoke Project is now testing project operations... |
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds configurable allowed file-extension restrictions for cache-memory and repo-memory, validates memory directories against those allow-lists, and surfaces validation failures in agent failure reporting (issues/comments). This fits into the workflow compiler + setup action tooling that generates locked workflows and orchestrates agent runs safely.
Changes:
- Introduces
allowed-extensionsconfiguration forcache-memoryandrepo-memory(schema/docs/constants) and updates prompts to mention allowed types. - Adds cache-memory validation steps in generated workflows and repo-memory validation during push, with failure outputs propagated into the conclusion failure handler.
- Refactors cache-memory multi-cache prompt into a reusable template file and adds a helper for generating inline
github-scriptsteps.
Reviewed changes
Copilot reviewed 97 out of 97 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/repo_memory_prompt.go | Updates repo-memory prompt text to mention allowed file types and new examples. |
| pkg/workflow/prompts_test.go | Updates workflow prompt generation tests to expect the new multi-cache prompt template reference. |
| pkg/workflow/prompts/cache_memory_prompt_multi.md | Adds a template for multi-cache cache-memory prompt content with placeholders. |
| pkg/workflow/prompts/cache_memory_prompt.md | Adds allowed file type messaging and updates examples for single-cache prompt template. |
| pkg/workflow/notify_comment.go | Passes repo-memory validation outputs into the agent failure handler via env vars. |
| pkg/workflow/compiler_yaml_main_job.go | Inserts cache-memory validation step generation after agent execution. |
| pkg/workflow/compiler_yaml_helpers.go | Adds helper to generate inline actions/github-script steps. |
| pkg/workflow/cache_memory_prompt_test.go | Updates cache-memory prompt unit tests for template-file-based multi-cache prompts + env var substitution. |
| pkg/workflow/cache_memory_integration_test.go | Updates integration tests to match template reference behavior. |
| pkg/workflow/cache_memory_import_test.go | Updates import tests to match template reference behavior. |
| pkg/parser/schemas/main_workflow_schema.json | Adds allowed-extensions to cache-memory and repo-memory schema definitions. |
| pkg/constants/constants.go | Defines default allowed extensions list for memory tools. |
| docs/src/content/docs/reference/frontmatter-full.md | Documents the new allowed-extensions fields for cache-memory and repo-memory. |
| actions/setup/md/agent_failure_issue.md | Adds repo-memory validation context placeholder to failure issue template. |
| actions/setup/md/agent_failure_comment.md | Adds repo-memory validation context placeholder to failure comment template. |
| actions/setup/js/validate_memory_files.cjs | Adds reusable JS helper to validate memory directories contain only allowed file types. |
| actions/setup/js/push_repo_memory.cjs | Validates repo-memory artifact contents against allowed extensions; sets step outputs on failure. |
| actions/setup/js/handle_agent_failure.cjs | Collects repo-memory validation outputs from env vars and renders them in failure reports. |
| .github/workflows/workflow-health-manager.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring. |
| .github/workflows/weekly-issue-summary.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/unbloat-docs.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/test-create-pr-error-handling.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/technical-doc-writer.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/super-linter.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/step-name-alignment.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/static-analysis-report.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/stale-repo-identifier.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/smoke-copilot.md | Adds allowed-repos: ["github/gh-aw"] restriction to add-comment safe output config. |
| .github/workflows/smoke-copilot.lock.yml | Regenerates locked workflow with updated safe-output config + cache-memory prompt substitutions + validation steps. |
| .github/workflows/smoke-codex.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/smoke-claude.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/slide-deck-maintainer.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/sergo.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/security-review.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/security-compliance.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring. |
| .github/workflows/scout.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/schema-consistency-checker.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/safe-output-health.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/repository-quality-improver.lock.yml | Regenerates locked workflow to use multi-cache prompt template + substitutions + validation steps. |
| .github/workflows/repo-audit-analyzer.lock.yml | Regenerates locked workflow to use multi-cache prompt template + substitutions + validation steps. |
| .github/workflows/q.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/python-data-charts.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/prompt-clustering-analysis.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/pr-triage-agent.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring. |
| .github/workflows/pr-nitpick-reviewer.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/portfolio-analyst.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/poem-bot.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/pdf-summary.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/org-health-report.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/metrics-collector.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring. |
| .github/workflows/mcp-inspector.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/lockfile-stats.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/jsweep.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/instructions-janitor.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/grumpy-reviewer.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/gpclean.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/go-logger.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/go-fan.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/glossary-maintainer.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/github-mcp-tools-report.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/github-mcp-structural-analysis.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/firewall-escape.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring + cache-memory validation steps. |
| .github/workflows/discussion-task-miner.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring. |
| .github/workflows/developer-docs-consolidator.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/delight.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring. |
| .github/workflows/deep-report.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring + cache-memory validation steps. |
| .github/workflows/daily-testify-uber-super-expert.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring. |
| .github/workflows/daily-safe-output-optimizer.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/daily-repo-chronicle.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/daily-performance-summary.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/daily-news.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring + cache-memory validation steps. |
| .github/workflows/daily-mcp-concurrency-analysis.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/daily-issues-report.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/daily-firewall-report.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/daily-doc-updater.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/daily-compiler-quality.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/daily-code-metrics.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring + cache-memory validation steps. |
| .github/workflows/daily-cli-performance.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring. |
| .github/workflows/copilot-cli-deep-research.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring. |
| .github/workflows/code-scanning-fixer.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring + cache-memory validation steps. |
| .github/workflows/cloclo.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/cli-version-checker.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/claude-code-user-docs-review.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/ci-doctor.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/ci-coach.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/chroma-issue-indexer.lock.yml | Regenerates locked workflow to use multi-cache prompt template + substitutions + validation steps. |
| .github/workflows/agent-persona-explorer.lock.yml | Regenerates locked workflow with cache-memory allowed extensions prompt substitution and validation steps. |
| .github/workflows/agent-performance-analyzer.lock.yml | Regenerates locked workflow with updated repo-memory prompt + validation outputs wiring. |
Comments suppressed due to low confidence (1)
pkg/workflow/repo_memory_prompt.go:101
- The multi-memory prompt uses
config.Memories[0].AllowedExtensionsto describe allowed file types. Becauseallowed-extensionsis configured per memory entry, this can be inaccurate when different memories have different allow-lists. Consider rendering allowed extensions per memory, or enforce/validate that all entries share the same extensions before using the first.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const extensions = allowedExtensions && allowedExtensions.length > 0 ? allowedExtensions : [".json", ".jsonl", ".txt", ".md", ".csv"]; | ||
| const invalidFiles = []; | ||
|
|
||
| // Check if directory exists | ||
| if (!fs.existsSync(memoryDir)) { | ||
| core.info(`Memory directory does not exist: ${memoryDir}`); | ||
| return { valid: true, invalidFiles: [] }; | ||
| } | ||
|
|
||
| /** | ||
| * Recursively scan directory for files | ||
| * @param {string} dirPath - Directory to scan | ||
| * @param {string} relativePath - Relative path from memory directory | ||
| */ | ||
| function scanDirectory(dirPath, relativePath = "") { | ||
| const entries = fs.readdirSync(dirPath, { withFileTypes: true }); | ||
|
|
||
| for (const entry of entries) { | ||
| const fullPath = path.join(dirPath, entry.name); | ||
| const relativeFilePath = relativePath ? path.join(relativePath, entry.name) : entry.name; | ||
|
|
||
| if (entry.isDirectory()) { | ||
| // Recursively scan subdirectory | ||
| scanDirectory(fullPath, relativeFilePath); | ||
| } else if (entry.isFile()) { | ||
| // Check file extension | ||
| const ext = path.extname(entry.name).toLowerCase(); | ||
| if (!extensions.includes(ext)) { | ||
| invalidFiles.push(relativeFilePath); |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validateMemoryFiles lowercases the scanned file extension but does not normalize allowedExtensions. If a workflow config supplies extensions with uppercase characters (e.g., ".MD"), validation will incorrectly reject files. Normalize allowedExtensions to lowercase (and ideally trim whitespace) before using includes.
| const maxFileSize = parseInt(process.env.MAX_FILE_SIZE || "10240", 10); | ||
| const maxFileCount = parseInt(process.env.MAX_FILE_COUNT || "100", 10); | ||
| const fileGlobFilter = process.env.FILE_GLOB_FILTER || ""; | ||
| const allowedExtensions = process.env.ALLOWED_EXTENSIONS ? JSON.parse(process.env.ALLOWED_EXTENSIONS) : [".json", ".jsonl", ".txt", ".md", ".csv"]; |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ALLOWED_EXTENSIONS is parsed with JSON.parse without error handling. If the env var is malformed, this will throw and fail the step with an unhelpful stack trace (and without setting validation outputs). Wrap parsing in a try/catch and core.setFailed with a clear message (and/or fall back to defaults).
| fmt.Fprintf(&validationScript, " const allowedExtensions = %s;\n", allowedExtsJSON) | ||
| fmt.Fprintf(&validationScript, " const result = validateMemoryFiles('%s', 'cache', allowedExtensions);\n", cacheDir) | ||
| validationScript.WriteString(" if (!result.valid) {\n") | ||
| fmt.Fprintf(&validationScript, " core.setFailed(`File type validation failed: Found $${result.invalidFiles.length} file(s) with invalid extensions. Only %s are allowed.`);\n", strings.Join(cache.AllowedExtensions, ", ")) |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generated JS template literal uses $${result.invalidFiles.length}, which will include an extra $ in the rendered error message (e.g., "Found $3 file(s)"). Use ${result.invalidFiles.length} instead so the count renders correctly.
| // Build allowed extensions text (use the first cache's extensions as they should all be the same for the group) | ||
| allowedExtsText := strings.Join(config.Caches[0].AllowedExtensions, ", ") |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For multi-cache prompts, the allowed extensions text is taken only from config.Caches[0] with a comment that all caches "should" be the same. Since allowed-extensions is configured per cache entry, this can produce incorrect guidance when caches have different allow-lists. Either validate at compile time that all caches share the same AllowedExtensions, or render per-cache allowed extensions (or a union) in the prompt.
| yaml.WriteString(" - **Automatic Push**: Changes are automatically committed and pushed after the workflow completes\n") | ||
| yaml.WriteString(" - **Merge Strategy**: In case of conflicts, your changes (current version) win\n") | ||
| yaml.WriteString(" - **Persistence**: Files persist across workflow runs via git branch storage\n") | ||
| yaml.WriteString(" - **Allowed File Types**: Only the following file extensions are allowed: `.json`, `.jsonl`, `.txt`, `.md`, `.csv`. Files with other extensions will be rejected during validation.\n") |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The prompt hardcodes the allowed file extensions list. Since allowed-extensions is configurable per repo-memory entry, this line can become incorrect and mislead agents when the workflow customizes extensions. Build this text from memory.AllowedExtensions (or the shared default) instead of a hard-coded list.
This issue also appears on line 99 of the same file.
|
✅ Smoke Project completed successfully. All project operations validated. |
|
PRs: Extract duplicate logic to safe output helper functions; Fix ReDoS in secret scanning regex patterns
|
|
🤖 beep boop The smoke test agent was here! 🎭 Just passing through on my daily rounds, testing all the things. Everything's looking ship-shape! May your workflows always compile and your tests always pass. ✨ (Smoke Test Run §21966079876)
|
Smoke Test ResultsPR #15240 - Add allowed-repos support to add-labels and close-issue safe outputs
Status: PASS ✅ cc @pelikhan
|
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
Agent Container Tool Check ✅
Result: 12/12 tools available ✅ All common development tools are accessible in the agent container environment.
|
Complete: Configurable File Type Restrictions with Failure Reporting ✅
Changes Implemented
1. Configurable File Extensions
allowed-extensionsfield to bothcache-memoryandrepo-memoryallowed-extensions: [".txt", ".csv", ".json"][".json", ".jsonl", ".txt", ".md", ".csv"]when not specified2. Code Refactoring
generateInlineGitHubScriptStep()helper for github-script code generationcache_memory_prompt_multi.mdtemplate for multi-cache promptspkg/constants/constants.goasDefaultAllowedMemoryExtensionsparseCacheMemoryEntry()helper that parses single cache object and is reused for both array and object syntax3. Validation Failure Reporting
validation_failed_{memory_id}andvalidation_error_{memory_id}handle_agent_failure.cjsto collect and report validation errors{repo_memory_validation_context}4. Smoke Test Configuration
allowed-repos: ["github/gh-aw"]restriction to smoke-copilot workflow's add-comment configurationExample Configuration
Example Validation Error in Failure Report
Code Quality Improvements
Testing
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Changeset