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

Recognize "403 forbidden" error from pip command output, and clasiffy it as "forbidden" error type #1225

Merged
merged 9 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions artifactory/commands/python/python.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package python

import (
"bytes"
"errors"
python "github.com/jfrog/jfrog-cli-core/v2/utils/python"
"io"
"os/exec"

"github.com/jfrog/build-info-go/build"
"github.com/jfrog/build-info-go/entities"
buildInfoUtils "github.com/jfrog/build-info-go/utils"
"github.com/jfrog/build-info-go/utils/pythonutils"
gofrogcmd "github.com/jfrog/gofrog/io"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/python/dependencies"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
buildUtils "github.com/jfrog/jfrog-cli-core/v2/common/build"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
python "github.com/jfrog/jfrog-cli-core/v2/utils/python"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/log"
"io"
"os"
"os/exec"
)

type PythonCommand struct {
Expand Down Expand Up @@ -71,7 +72,24 @@ func (pc *PythonCommand) Run() (err error) {
err = errorutils.CheckError(pythonModule.RunInstallAndCollectDependencies(pc.args))
} else {
// Python native command
err = gofrogcmd.RunCmd(pc)
for k, v := range pc.GetEnv() {
if err := os.Setenv(k, v); err != nil {
return err
}
}

cmd := pc.GetCmd()
errBuffer := bytes.NewBuffer([]byte{})
multiWriter := io.MultiWriter(os.Stderr, errBuffer)
cmd.Stderr = multiWriter
cmd.Stdout = os.Stdout

err = cmd.Run()
if err != nil {
if buildInfoUtils.IsForbiddenOutput(buildInfoUtils.Pip, errBuffer.String()) {
err = errors.Join(err, buildInfoUtils.NewForbiddenError())
}
}
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ require (

// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240811142930-ab9715567376

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20240804091815-7407ceb49077
replace github.com/jfrog/build-info-go => github.com/asafambar/build-info-go v1.8.9-0.20240819133117-c3f52700927d

// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.3.3-0.20231223133729-ef57bd08cedc
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/asafambar/build-info-go v1.8.9-0.20240819133117-c3f52700927d h1:GS9yDbl7Moer5ODbWu+DPcQtyCYlmRL4TAdt1l+b/Vo=
github.com/asafambar/build-info-go v1.8.9-0.20240819133117-c3f52700927d/go.mod h1:6mdtqjREK76bHNODXakqKR/+ksJ9dvfLS7H57BZtnLY=
github.com/bradleyjkemp/cupaloy/v2 v2.8.0 h1:any4BmKE+jGIaMpnU8YgH/I2LPiLBufr6oMMlVBbn9M=
github.com/bradleyjkemp/cupaloy/v2 v2.8.0/go.mod h1:bm7JXdkRd4BHJk9HpwqAI8BoAY1lps46Enkdqw6aRX0=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
Expand Down Expand Up @@ -92,8 +94,6 @@ github.com/jedib0t/go-pretty/v6 v6.5.9 h1:ACteMBRrrmm1gMsXe9PSTOClQ63IXDUt03H5U+
github.com/jedib0t/go-pretty/v6 v6.5.9/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E=
github.com/jfrog/archiver/v3 v3.6.1 h1:LOxnkw9pOn45DzCbZNFV6K0+6dCsQ0L8mR3ZcujO5eI=
github.com/jfrog/archiver/v3 v3.6.1/go.mod h1:VgR+3WZS4N+i9FaDwLZbq+jeU4B4zctXL+gL4EMzfLw=
github.com/jfrog/build-info-go v1.9.33 h1:TEeTHDc3tEwZe/7kKhm1hQDd5vA/HnVhp1ZczUOWExk=
github.com/jfrog/build-info-go v1.9.33/go.mod h1:JTGnENexG1jRhKWCkQtZuDb0PerlzlSzF5OmMLG9kfc=
github.com/jfrog/gofrog v1.7.5 h1:dFgtEDefJdlq9cqTRoe09RLxS5Bxbe1Ev5+E6SmZHcg=
github.com/jfrog/gofrog v1.7.5/go.mod h1:jyGiCgiqSSR7k86hcUSu67XVvmvkkgWTmPsH25wI298=
github.com/jfrog/jfrog-client-go v1.44.1 h1:Dj2+gIWMInHe7MWX3XLRhPRnlFOm7jnbCrGSgFDSMFY=
Expand Down
Loading