j178 / leetgo

Best LeetCode friend for geek. :snowboarder:
MIT License
540 stars 32 forks source link

[Bug] ```leetgo pick``` not working #310

Closed veryshyjelly closed 3 weeks ago

veryshyjelly commented 1 month ago

leetgo debug

● retry url=https://leetcode.com/problems/api/tags/ attempt=0 error="[403 Forbidden] " ● retry url=https://leetcode.com/problems/api/tags/ attempt=1 error="[403 Forbidden] " ● retry url=https://leetcode.com/problems/api/tags/ attempt=2 error="[403 Forbidden] " × [403 Forbidden]

Debug log

.

Description

leetgo pick is not working

noodleslove commented 4 weeks ago

I encountered a similar error.

Error when running leetgo pick command: Crypto/cipher input block error when accessing Chrome cookies

Description

When running the leetgo pick command, the program crashes with a panic error related to decrypting Chrome cookies. The error suggests there's an issue with the block size of encrypted data when trying to access browser credentials.

Error Message

panic: crypto/cipher: input not full blocks

goroutine 1 [running]:
crypto/cipher.(*cbcDecrypter).CryptBlocks(0x103734d50?, {0x1400140e000?, 0x14001406010?, 0x10?}, {0x14001279ae3?, 0x9?, 0x3eb?})
        crypto/cipher/cbc.go:145 +0x384
github.com/j178/kooky/internal/chrome.decryptAESCBC({0x14001279ae0, 0x4d, 0x50}, {0x14001404000, 0x18, 0x18}, 0x3eb)
        github.com/j178/kooky@v0.0.0-20240103045155-c09911743d37/internal/chrome/chrome.go:299 +0x144
github.com/j178/kooky/internal/chrome.(*CookieStore).decrypt.func2({0x14001279ae0?, 0x14001286501?, 0x103113a39?}, {0x14001404000?, 0x1035e1240?, 0x102723658?})
        github.com/j178/kooky@v0.0.0-20240103045155-c09911743d37/internal/chrome/chrome.go:216 +0x28
github.com/j178/kooky/internal/chrome.(*CookieStore).decrypt(0x1400075c870, {0x14001279ae0, 0x4d, 0x50})
        github.com/j178/kooky@v0.0.0-20240103045155-c09911743d37/internal/chrome/chrome.go:254 +0x740
github.com/j178/kooky/internal/chrome.decryptCookieValue(0x1400075c870, 0x1400132dba0, {0x1400070d5c0?, 0x14001315860?})
        github.com/j178/kooky@v0.0.0-20240103045155-c09911743d37/internal/chrome/chrome.go:108 +0x78
github.com/j178/kooky/internal/chrome.(*CookieStore).ReadCookies.func1(0x10?, {0x1400070d5c0?, 0x14001315860?})
        github.com/j178/kooky@v0.0.0-20240103045155-c09911743d37/internal/chrome/chrome.go:83 +0x400
github.com/j178/kooky/internal/utils.VisitTableRows.func1(0x1400133e928, {{0x15, {0x1400132fd00, 0x14, 0x20}}, {0x14000409696, 0x114, 0x114}, {0x14001343200, 0x14, ...}})
        github.com/j178/kooky@v0.0.0-20240103045155-c09911743d37/internal/utils/visittablerows.go:25 +0xbc
github.com/go-sqlite/sqlite3.(*DbFile).VisitTableRecords.(*btreeTable).visitRecordsInorder.func1({0x0, 0x1400133e928, {0x14000409680, 0x12a, 0x12a}, 0x0})
        github.com/go-sqlite/sqlite3@v0.0.0-20180313105335-53dd8e640ee7/btree.go:431 +0xec
github.com/go-sqlite/sqlite3.(*btreeTable).visitRawInorder(0x140008130e0, 0x14001286db0)
        github.com/go-sqlite/sqlite3@v0.0.0-20180313105335-53dd8e640ee7/btree.go:395 +0x15c
github.com/go-sqlite/sqlite3.(*btreeTable).visitRawInorder(0x140008125a0, 0x14001286db0)
        github.com/go-sqlite/sqlite3@v0.0.0-20180313105335-53dd8e640ee7/btree.go:387 +0x128
github.com/go-sqlite/sqlite3.(*btreeTable).visitRawInorder(0x14000812540, 0x14001286db0)
        github.com/go-sqlite/sqlite3@v0.0.0-20180313105335-53dd8e640ee7/btree.go:387 +0x128
github.com/go-sqlite/sqlite3.(*btreeTable).visitRecordsInorder(...)
        github.com/go-sqlite/sqlite3@v0.0.0-20180313105335-53dd8e640ee7/btree.go:424
github.com/go-sqlite/sqlite3.(*DbFile).VisitTableRecords(0x14000715ad0, {0x103118c58, 0x7}, 0x14001286ed0)
        github.com/go-sqlite/sqlite3@v0.0.0-20180313105335-53dd8e640ee7/file.go:313 +0x13c
github.com/j178/kooky/internal/utils.VisitTableRows(0x14000715ad0, {0x103118c58, 0x7}, 0x14001287068, 0x14001287098)
        github.com/j178/kooky@v0.0.0-20240103045155-c09911743d37/internal/utils/visittablerows.go:24 +0x270
github.com/j178/kooky/internal/chrome.(*CookieStore).ReadCookies(0x1400075c870, {0x14000694360, 0x2, 0x2})
        github.com/j178/kooky@v0.0.0-20240103045155-c09911743d37/internal/chrome/chrome.go:38 +0x174
github.com/j178/leetgo/leetcode.(*browserAuth).AddCredentials(0x140005b86c0, 0x14000412240)
        github.com/j178/leetgo/leetcode/credential.go:169 +0x350
github.com/j178/leetgo/leetcode.(*cnClient).send(0x14000897440, 0x14000412240, 0x14000560100?, {0x1035d6540, 0x14001137408})
        github.com/j178/leetgo/leetcode/client.go:201 +0x9c
github.com/j178/leetgo/leetcode.(*cnClient).graphqlPost(0x14000897440, {{0x0, 0x0}, {0x10316d091, 0x1d8}, {0x10312941c, 0xc}, 0x1400070c150, 0x0}, {0x1035d6540, ...})
        github.com/j178/leetgo/leetcode/client.go:300 +0x434
github.com/j178/leetgo/leetcode.(*cnClient).getQuestionData(0x14000897440, {0x140011158ce, 0x10}, {0x10316d091, 0x1d8}, 0x0)
        github.com/j178/leetgo/leetcode/client.go:442 +0x118
github.com/j178/leetgo/leetcode.(*usClient).GetQuestionData(0x14000897440, {0x140011158ce?, 0x10000001010048?})
        github.com/j178/leetgo/leetcode/client_us.go:65 +0x38
github.com/j178/leetgo/leetcode.(*QuestionData).Fulfill(0x14001116788)
        github.com/j178/leetgo/leetcode/question.go:363 +0x80
github.com/j178/leetgo/lang.generate(0x14001116788)
        github.com/j178/leetgo/lang/gen.go:49 +0x5c
github.com/j178/leetgo/lang.Generate(0x14001116788)
        github.com/j178/leetgo/lang/gen.go:113 +0x28
github.com/j178/leetgo/cmd.init.func18(0x103f86320?, {0x14000049ce0, 0x1, 0x10311071b?})
        github.com/j178/leetgo/cmd/pick.go:135 +0x17c
github.com/spf13/cobra.(*Command).execute(0x103f86320, {0x14000049c90, 0x1, 0x1})
        github.com/spf13/cobra@v1.8.1/command.go:985 +0x840
github.com/spf13/cobra.(*Command).ExecuteC(0x103f85a80)
        github.com/spf13/cobra@v1.8.1/command.go:1117 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.8.1/command.go:1041
github.com/j178/leetgo/cmd.Execute()
        github.com/j178/leetgo/cmd/root.go:52 +0x24
main.main()
        github.com/j178/leetgo/main.go:6 +0x1c

The error originates from the cookie decryption process in the Chrome credential provider (github.com/j178/kooky/internal/chrome).

Environment

Configuration

Stack Trace Analysis

The error occurs in the following sequence:

  1. During the graphqlPost operation for fetching question data
  2. While attempting to authenticate using Chrome browser cookies
  3. Specifically fails in the cookie decryption process (decryptAESCBC function)

Steps to Reproduce

  1. Configure leetgo with browser-based authentication using Chrome
  2. Run leetgo pick command
  3. Program crashes with the crypto/cipher panic
j178 commented 4 weeks ago

Chrome appears to have updated its cookie database encryption in recent releases, preventing leetgo from being able to decrypt them. I'm uncertain how to address this, but I will investigate further.

j178 commented 4 weeks ago

follow https://github.com/browserutils/kooky/issues/89

j178 commented 3 weeks ago

@noodleslove I released v1.4.10 to fix the chrome cookie decryption issue, please check it out, thanks!