-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(workflows): symmetric fallback chain — workspace + global tiers for scripts/commands #1144
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
Changes from all commits
25c9a79
196c564
d882305
8ac34dc
c321239
7faf57d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ import { access, rm } from 'fs/promises'; | |
| import { join, basename, resolve } from 'path'; | ||
| import * as codebaseDb from '../db/codebases'; | ||
| import { sanitizeError } from '../utils/credential-sanitizer'; | ||
| import { execFileAsync } from '@archon/git'; | ||
| import { execFileAsync, parseOwnerRepoFromRemoteUrl } from '@archon/git'; | ||
| import { | ||
| expandTilde, | ||
| getCommandFolderSearchPaths, | ||
|
|
@@ -385,21 +385,14 @@ export async function registerRepository( | |
| // Extract repo name from directory name | ||
| const repoName = basename(localPath); | ||
|
|
||
| // Try to build owner/repo name from remote URL | ||
| // Try to build owner/repo name from remote URL via the shared parser | ||
| let name = repoName; | ||
| let ownerName = '_local'; | ||
| if (remoteUrl) { | ||
| const cleaned = remoteUrl.replace(/\.git$/, '').replace(/\/+$/, ''); | ||
| let workingRemote = cleaned; | ||
| if (cleaned.startsWith('git@github.com:')) { | ||
| workingRemote = cleaned.replace('git@github.com:', 'https://github.com/'); | ||
| } | ||
| const parts = workingRemote.split('/'); | ||
| const r = parts.pop(); | ||
| const o = parts.pop(); | ||
| if (o && r) { | ||
| name = `${o}/${r}`; | ||
| ownerName = o; | ||
| const parsed = parseOwnerRepoFromRemoteUrl(remoteUrl); | ||
| if (parsed) { | ||
| name = `${parsed.owner}/${parsed.repo}`; | ||
| ownerName = parsed.owner; | ||
| } | ||
|
Comment on lines
+388
to
396
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate parsed remote owner/repo before using them for project paths. Line 392-396 trusts 🔒 Proposed fix- if (remoteUrl) {
- const parsed = parseOwnerRepoFromRemoteUrl(remoteUrl);
- if (parsed) {
- name = `${parsed.owner}/${parsed.repo}`;
- ownerName = parsed.owner;
- }
- }
+ if (remoteUrl) {
+ const parsedRemote = parseOwnerRepoFromRemoteUrl(remoteUrl);
+ if (parsedRemote) {
+ const normalizedRepo = parsedRemote.repo.replace(/\.git$/, '');
+ const safe = parseOwnerRepo(`${parsedRemote.owner}/${normalizedRepo}`);
+ if (safe) {
+ name = `${safe.owner}/${safe.repo}`;
+ ownerName = safe.owner;
+ } else {
+ getLog().warn({ remoteUrl }, 'remote_owner_repo_invalid');
+ }
+ }
+ }🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
|
|
||
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.
Harden workspace path resolution against unsafe remote segments.
Line 127-129 uses remote-derived owner/repo directly in
getProjectRoot(). If origin contains malformed segments (e.g.,..), discovery can probe outside the intended workspace subtree. Validate/sanitize first, then skip workspace tier when invalid.🛡️ Proposed fix
🤖 Prompt for AI Agents