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

Replace most occurances of http with https when the https url is valid #52566

Merged
merged 4 commits into from
Jan 3, 2024

Conversation

LilithHafner
Copy link
Member

I searched the repo for "http:...", checked if equivalent "https:..." urls returned 200 status codes without authentication errors, and replace all occurances that did. Then I performed a manual review and reverted cases that should remain "http:".

Here's the script that performed the original replacement

using Random, HTTP
# disallow ) in url because it is so common to have [x](example.com)
links = readlines(`ag -o --nofilename --nogroup --hidden "http:[A-Za-z0-9-._~:/?#\[\]@-l&'(*+,;%=]+"`)
filter!(!isempty, links)
unique!(links)

replacements = []
for link in shuffle!(links)
    link_secure = link[1:4] * "s" * link[5:end]

    status = try
        HTTP.get(link_secure, retry=false, connect_timeout=5, read_timeout=10).status
    catch e
        nothing
    end
    if status === Int16(200)
        push!(replacements, link => link_secure)
        println("okay: ", link_secure)
    else
        println("fail: ", link_secure)
    end
end


###
files = reduce(vcat, (readlines(`ag -Q --hidden -l $(r[1])`) for r in replacements))
unique!(sort!(files))
for file in files
    content = read(file, String)
    for r in replacements
        content = replace(content, r)
    end
    open(file, "w") do io
        write(io, content)
    end
end

This should be minor and mostly NFC.

@LilithHafner LilithHafner added the security System security concerns and vulnerabilities label Dec 17, 2023
@LilithHafner LilithHafner merged commit 0f6c72c into master Jan 3, 2024
5 of 7 checks passed
@LilithHafner LilithHafner deleted the lh/https-1 branch January 3, 2024 21:48
Lainezs

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
security System security concerns and vulnerabilities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants