Skip to content
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

Allow general URL to import JCCommands from. -- receiving '400: Invalid request' #472

Open
flybyray opened this issue Feb 23, 2023 · 1 comment

Comments

@flybyray
Copy link

flybyray commented Feb 23, 2023

'The URL of the JumpCloud command to import into a JumpCloud tenant.' see

[Parameter(ParameterSetName = 'URL', Mandatory, Position = 0, ValueFromPipelineByPropertyName = $True, HelpMessage = 'The URL of the JumpCloud command to import into a JumpCloud tenant.')]

command:

Import-JCCommand -URL "http://localhost:9000/JumpCloud_Commands/Mac%20Commands/Mac%20-%20List%20additional%20routes%20from%20vpn.md"

error and stacktrace:

Invoke-WebRequest: /home/username/.local/share/powershell/Modules/JumpCloud/2.2.0/Private/NestedFunctions/New-JCCommandFromURL.ps1:20
Line |
  20 |  … UrlInvoke = Invoke-WebRequest -Uri $rawUrl -UseBasicParsing -UserAgen …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | 400: Invalid request
InvalidOperation: /home/username/.local/share/powershell/Modules/JumpCloud/2.2.0/Private/NestedFunctions/New-JCCommandFromURL.ps1:24
Line |
  24 |          $Name = $content[0].Groups[2].Value #Name
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot index into a null array.
InvalidOperation: /home/username/.local/share/powershell/Modules/JumpCloud/2.2.0/Private/NestedFunctions/New-JCCommandFromURL.ps1:25
Line |
  25 |          $commandType = $content[1].Groups[2].Value #CommandType
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot index into a null array.
InvalidOperation: /home/username/.local/share/powershell/Modules/JumpCloud/2.2.0/Private/NestedFunctions/New-JCCommandFromURL.ps1:26
Line |
  26 |          $Command = $content[2].Groups[3].Value #Command
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot index into a null array.

reason:

$httpUrl = $GitHubURL | Select-String -Pattern "\bmaster.*$" | % { $_.Matches } | % { $_.Value }
$rawUrl = "https://raw.githubusercontent.com/TheJumpCloud/support/$httpUrl"

URL is transformed and not a general URL is expected as described by help text.

Could you allow to import JC Commands from different URLs?

flybyray added a commit to flybyray/support that referenced this issue Feb 23, 2023
@flybyray
Copy link
Author

Apply patch as workarround.

patch -p1 /home/username/.local/share/powershell/Modules/JumpCloud/2.2.0/Private/NestedFunctions/New-JCCommandFromURL.ps1 < <(curl -fsSL https://github.com/flybyray/support/commit/73c5fbc4d13b871ce472ecbe43266fb2d988218f.patch)

replace /home/username/.local/share/powershell/Modules/JumpCloud/2.2.0/Private/NestedFunctions/New-JCCommandFromURL.ps1 with the correct path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant