Conversation
|
🔐 Smoke tests approved by maintainer ⏳ Running security scans before executing smoke tests with secrets... A maintainer has approved this fork PR to run smoke tests. Security scans will run first. |
|
❌ Some smoke tests failed. (Fork PR) ✅ Security Scan: success |
7ff04a5 to
02bad48
Compare
| func missingPowerShellBlocks(existingContent string) string { | ||
| var script string | ||
|
|
||
| if !strings.Contains(existingContent, version.CliName+" completion powershell") { |
There was a problem hiding this comment.
Main PowerShell block detection has false positive from alias
Low Severity
The idempotency check in missingPowerShellBlocks uses strings.Contains(existingContent, version.CliName+" completion powershell") to detect whether the main completion block is already installed. However, the alias block's body also contains the string "dr completion powershell" (in the Invoke-Expression line). If the main block is ever removed while the alias block remains, this check falsely concludes the main block still exists, preventing it from being re-added. The alias block check at line 463 correctly uses the unique marker "# datarobot alias completion", but the main block check lacks similar specificity — it could use "# " + version.CliName + " completion" instead.
ajalon1
left a comment
There was a problem hiding this comment.
Is this going to work with Homebrew installs, then?
@ajalon1 I think https://github.com/datarobot-oss/cli/pull/397/changes#diff-b29ed83747f43cc9c81631fead08e0867c73166e8e841b655ee92bcd2f54596dR85 should make that work 🤞 |
02bad48 to
51db951
Compare
| fmt.Fprintf(&sb, "if (Get-Command %s -ErrorAction SilentlyContinue) {\n", alias) | ||
| fmt.Fprintf(&sb, " %s completion powershell | Out-String | Invoke-Expression\n", version.CliName) | ||
| sb.WriteString("}\n") | ||
| } |
There was a problem hiding this comment.
PowerShell alias completion registers for wrong command name
Medium Severity
The PowerShell alias completion block runs dr completion powershell | Out-String | Invoke-Expression, which calls GenPowerShellCompletionWithDesc under the hood. Cobra generates Register-ArgumentCompleter -Native -CommandName 'dr' based on Root().Name() (derived from Use: "dr"), so completions are only registered for dr, never for datarobot. The other shells handle this correctly — bash uses complete -F __start_dr datarobot, fish uses complete --command datarobot --wraps dr, and zsh creates a _datarobot file delegating to _dr — but PowerShell has no equivalent mapping for the alias command name.
| continue | ||
| } | ||
|
|
||
| $isMarker = ($line -match "# $BINARY_NAME completion") -or ($line -match "# .+ alias completion") |
There was a problem hiding this comment.
Overly broad regex matches unrelated PowerShell profile content
Medium Severity
The marker detection regex "# .+ alias completion" matches any line containing that pattern (e.g., # git alias completion or # my custom alias completion), not just lines written by this tool. The equivalent Go function isCompletionMarker correctly checks for specific alias names from version.CliAliases. This mismatch means the PowerShell uninstaller could accidentally delete unrelated blocks from the user's profile by skipping 3 lines after a false-positive match.


RATIONALE
Added
datarobotas a command alias after hearing an AI call itd-rocterfor the last time 😆CHANGES
Added support for alias commands, and install the
datarobotalias for all systems and ensured completions worksNote
Medium Risk
Medium risk because it changes installer/uninstaller behavior across multiple shells and platforms (creating/removing alias binaries and modifying completion/profile files), which can impact user environments if paths or markers are wrong.
Overview
Adds a first-class
datarobotalias for thedrCLI across distribution paths (curl install scripts, Windows installer, and Homebrew cask) by creating a symlink/hardlink alongside the primary binary.Updates completion install/uninstall flows to also generate and remove completions for alias names (Zsh/Bash/Fish plus PowerShell profile blocks), including more granular PowerShell detection/appending and alias-aware removal markers.
Extends smoke tests to assert the
datarobotalias exists and produces the same basic output asdr, and updates uninstall tests/logic to account for the additional completion files.Written by Cursor Bugbot for commit 51db951. This will update automatically on new commits. Configure here.