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

feat(autoupdate): Try decoding invalid hash value with base64 in format_hash #6272

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

AkariiinMKII
Copy link
Contributor

@AkariiinMKII AkariiinMKII commented Jan 15, 2025

Description

This PR moves base64 decoding process to format_hash function, which is formerly in find_hash_in_textfile and find_hash_in_headers, and add debug output before formatting.

It will make following effects:

  • find_hash_in_rdf: Try decoding invalid hash value with base64.
  • find_hash_in_textfile: Additionally try decoding invalid hash value found by file name with base64.
  • find_hash_in_json: Try decoding invalid hash value with base64 (Aimed to solve issue [Feature] Decode base64 hash value fetched in json mode  #6271).
  • find_hash_in_xml: Try decoding invalid hash value with base64.
  • find_hash_in_headers: Skip decoding if fetched hash value is valid.

It should not affect valid hash value that matches the format.

Motivation and Context

Closes #6271

How Has This Been Tested?

Tested with checkver.ps1

For related issue, use json mode in wolai manifest:

...
"hash": {
  "mode": "json",
  "url": "https://cdn.wostatic.cn/dist/installers/electron-versions.json",
  "jsonpath": "$.win.sha512"
}

Contents in url:

...
"win": {
        "version": "1.2.11",
        "files": [
            {
                "url": "wolai.Setup.1.2.11.exe",
                "sha512": "JbiQs0Oi3jWZPmu06EpVdZM/CsfXR1NKkI1hRAZ/3x8GIBWbVsuJn+ku/i6z3eefbwU7Co4hLiOy7cY+3dN4+Q==",
                "size": 65819904
            }
        ],
        "path": "wolai.Setup.1.2.11.exe",
        "sha512": "JbiQs0Oi3jWZPmu06EpVdZM/CsfXR1NKkI1hRAZ/3x8GIBWbVsuJn+ku/i6z3eefbwU7Co4hLiOy7cY+3dN4+Q==",
        "releaseDate": "2024-11-29T08:33:05.283Z"
    },

Before changes

> .\bin\checkver.ps1 -app C:\Users\A1\scoop\buckets\scoop4kariiin\bucket\wolai.json -f
wolai: 1.2.11 (scoop version is 1.2.11)
Forcing autoupdate!
Autoupdating wolai
Searching hash for wolai Setup 1.2.11.exe in https://cdn.wostatic.cn/dist/installers/electron-versions.json
Could not find hash in https://cdn.wostatic.cn/dist/installers/electron-versions.json
Downloading wolai Setup 1.2.11.exe to compute hashes!
wolai%20Setup%201.2.11.exe (62.8 MB) [========================================================================] 100%
Computed hash: d29b503f700c644d130fdccb93079011b2488912c4b140776f6783680a666281
Writing updated wolai manifest

After changes

> .\bin\checkver.ps1 -app C:\Users\A1\scoop\buckets\scoop4kariiin\bucket\wolai.json -f
wolai: 1.2.11 (scoop version is 1.2.11)
Forcing autoupdate!
Autoupdating wolai
Searching hash for wolai Setup 1.2.11.exe in https://cdn.wostatic.cn/dist/installers/electron-versions.json
Found: sha512:25b890b343a2de35993e6bb4e84a5575933f0ac7d747534a908d6144067fdf1f0620159b56cb899fe92efe2eb3dde79f6f053b0a8e212e23b2edc63eddd378f9 using Json Mode
Writing updated wolai manifest

Checklist:

  • I have read the Contributing Guide.
  • I have ensured that I am targeting the develop branch.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.
  • I have added an entry in the CHANGELOG.

@AkariiinMKII AkariiinMKII marked this pull request as draft January 18, 2025 03:32
@AkariiinMKII AkariiinMKII changed the title feat(autoupdate): Add base64 decoding for hash values fetched in json… feat(autoupdate): Try decoding base64 encoded hash values in format_hash Jan 18, 2025
@AkariiinMKII AkariiinMKII marked this pull request as ready for review January 18, 2025 13:55
@AkariiinMKII AkariiinMKII changed the title feat(autoupdate): Try decoding base64 encoded hash values in format_hash feat(autoupdate): Try decoding invalid hash value with base64 in format_hash Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant