From d14778850150fe467ffa6a404517a4b21c6dd2c9 Mon Sep 17 00:00:00 2001 From: Majd Alfhaily Date: Sun, 19 Jan 2025 23:39:03 +0100 Subject: [PATCH 1/2] Bump deprecated actions versions --- .github/workflows/integration-tests.yml | 4 ++-- .github/workflows/issues-cleanup.yml | 18 ------------------ .github/workflows/release.yml | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/issues-cleanup.yml diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 7494264a..fd13fc85 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -21,7 +21,7 @@ jobs: env: CGO_CFLAGS: -mmacosx-version-min=10.15 CGO_LDFLAGS: -mmacosx-version-min=10.15 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ipatool path: ipatool @@ -35,7 +35,7 @@ jobs: matrix: command: [auth, download, purchase, search] steps: - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v4 with: name: ipatool path: build diff --git a/.github/workflows/issues-cleanup.yml b/.github/workflows/issues-cleanup.yml deleted file mode 100644 index 6dcf7af7..00000000 --- a/.github/workflows/issues-cleanup.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Issues Cleanup - -on: - issue_comment: - types: [created] - schedule: - - cron: "0 */6 * * *" # every 6 hours - -jobs: - scan-issues: - runs-on: ubuntu-latest - steps: - - uses: lee-dohm/no-response@v0.5.0 - with: - token: ${{ github.token }} - daysUntilClose: 7 - closeComment: This issue has been automatically closed because there has been no response from the original author. - responseRequiredLabel: auto-close diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 027cc8e1..0c73c5f5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -71,32 +71,32 @@ jobs: CGO_CFLAGS: -mmacosx-version-min=10.15 CGO_LDFLAGS: -mmacosx-version-min=10.15 CGO_ENABLED: 1 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ipatool-${{ needs.get_version.outputs.version }}-windows-arm64.exe path: ipatool-${{ needs.get_version.outputs.version }}-windows-arm64.exe if-no-files-found: error - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ipatool-${{ needs.get_version.outputs.version }}-windows-amd64.exe path: ipatool-${{ needs.get_version.outputs.version }}-windows-amd64.exe if-no-files-found: error - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ipatool-${{ needs.get_version.outputs.version }}-linux-arm64 path: ipatool-${{ needs.get_version.outputs.version }}-linux-arm64 if-no-files-found: error - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ipatool-${{ needs.get_version.outputs.version }}-linux-amd64 path: ipatool-${{ needs.get_version.outputs.version }}-linux-amd64 if-no-files-found: error - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64 path: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64 if-no-files-found: error - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64 path: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64 @@ -111,7 +111,7 @@ jobs: arch: [ arm64, amd64 ] steps: - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v4 with: name: ipatool-${{ needs.get_version.outputs.version }}-windows-${{ matrix.arch }}.exe path: bin @@ -138,7 +138,7 @@ jobs: arch: [ arm64, amd64 ] steps: - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v4 with: name: ipatool-${{ needs.get_version.outputs.version }}-linux-${{ matrix.arch }} path: bin @@ -163,14 +163,14 @@ jobs: - uses: actions/checkout@v2 with: path: ./ipatool - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v4 with: name: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64 path: bin - run: tar -czvf $BIN.tar.gz bin/$BIN && rm -rf bin/ env: BIN: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64 - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v4 with: name: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64 path: bin From f3c9076ff0c53d7f2966a71697c4001b6071c8ba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 00:00:00 +0100 Subject: [PATCH 2/2] Bump golang.org/x/net from 0.23.0 to 0.33.0 (#334) * Bump golang.org/x/net from 0.23.0 to 0.33.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.23.0 to 0.33.0. - [Commits](https://github.com/golang/net/compare/v0.23.0...v0.33.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production ... Signed-off-by: dependabot[bot] * Fix linting errors --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Majd Alfhaily --- go.mod | 14 +++++++------- go.sum | 29 +++++++++++++++-------------- pkg/appstore/appstore_login.go | 28 +++++++++++++++++++++------- pkg/http/client.go | 1 + pkg/http/result.go | 1 + 5 files changed, 45 insertions(+), 28 deletions(-) diff --git a/go.mod b/go.mod index c99896f5..806b0a4b 100644 --- a/go.mod +++ b/go.mod @@ -13,8 +13,8 @@ require ( github.com/spf13/cobra v1.6.1 github.com/thediveo/enumflag/v2 v2.0.1 go.uber.org/mock v0.4.0 - golang.org/x/net v0.23.0 - golang.org/x/term v0.18.0 + golang.org/x/net v0.33.0 + golang.org/x/term v0.27.0 howett.net/plist v1.0.0 ) @@ -24,7 +24,7 @@ require ( github.com/dvsekhvalnov/jose2go v1.6.0 // indirect github.com/go-logr/logr v1.2.3 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/juju/go4 v0.0.0-20160222163258-40d72ab9641a // indirect @@ -37,10 +37,10 @@ require ( github.com/rivo/uniseg v0.2.0 // indirect github.com/spf13/pflag v1.0.5 // indirect golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.17.0 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect gopkg.in/errgo.v1 v1.0.1 // indirect gopkg.in/retry.v1 v1.0.3 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 686ba6d1..57a8b0f6 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6 github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/google/go-cmp v0.2.1-0.20190312032427-6f77996f0c42/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= @@ -88,24 +88,25 @@ go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= diff --git a/pkg/appstore/appstore_login.go b/pkg/appstore/appstore_login.go index 642301fc..86db009b 100644 --- a/pkg/appstore/appstore_login.go +++ b/pkg/appstore/appstore_login.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + gohttp "net/http" "strconv" "strings" @@ -63,18 +64,24 @@ type loginResult struct { func (t *appstore) login(email, password, authCode, guid string) (Account, error) { redirect := "" - var err error + + var ( + err error + res http.Result[loginResult] + ) + retry := true - var res http.Result[loginResult] for attempt := 1; retry && attempt <= 4; attempt++ { ac := authCode if attempt == 1 { ac = "" } + request := t.loginRequest(email, password, ac, guid, attempt) - request.URL, redirect = util.IfEmpty(redirect, request.URL), "" + request.URL, _ = util.IfEmpty(redirect, request.URL), "" res, err = t.loginClient.Send(request) + if err != nil { return Account{}, fmt.Errorf("request failed: %w", err) } @@ -116,8 +123,14 @@ func (t *appstore) login(email, password, authCode, guid string) (Account, error return acc, nil } -func (t *appstore) parseLoginResponse(res *http.Result[loginResult], attempt int, authCode string) (retry bool, redirect string, err error) { - if res.StatusCode == 302 { +func (t *appstore) parseLoginResponse(res *http.Result[loginResult], attempt int, authCode string) (bool, string, error) { + var ( + retry bool + redirect string + err error + ) + + if res.StatusCode == gohttp.StatusFound { if redirect, err = res.GetHeader("location"); err != nil { err = fmt.Errorf("failed to retrieve redirect location: %w", err) } else { @@ -133,10 +146,11 @@ func (t *appstore) parseLoginResponse(res *http.Result[loginResult], attempt int } else { err = NewErrorWithMetadata(errors.New("something went wrong"), res) } - } else if res.StatusCode != 200 || res.Data.PasswordToken == "" || res.Data.DirectoryServicesID == "" { + } else if res.StatusCode != gohttp.StatusOK || res.Data.PasswordToken == "" || res.Data.DirectoryServicesID == "" { err = NewErrorWithMetadata(errors.New("something went wrong"), res) } - return + + return retry, redirect, err } func (t *appstore) loginRequest(email, password, authCode, guid string, attempt int) http.Request { diff --git a/pkg/http/client.go b/pkg/http/client.go index d9d4a4a7..a6369b40 100644 --- a/pkg/http/client.go +++ b/pkg/http/client.go @@ -57,6 +57,7 @@ func NewClient[R interface{}](args Args) Client[R] { if req.Referer() == appStoreAuthURL { return http.ErrUseLastResponse } + return nil }, Transport: &AddHeaderTransport{http.DefaultTransport}, diff --git a/pkg/http/result.go b/pkg/http/result.go index 0afd468c..f8537d34 100644 --- a/pkg/http/result.go +++ b/pkg/http/result.go @@ -22,5 +22,6 @@ func (c *Result[R]) GetHeader(key string) (string, error) { return v, nil } } + return "", ErrHeaderNotFound }