diff options
author | Matt Arnold <matt@thegnuguru.org> | 2023-06-05 22:00:26 -0400 |
---|---|---|
committer | Matt Arnold <matt@thegnuguru.org> | 2023-06-05 22:00:26 -0400 |
commit | 484ca735031d3bec2534d16a73e4c6626dae8daa (patch) | |
tree | 5ed0144c1b7551151c62bc46c65c3d4f860d943a | |
parent | eaa5346068abc28cfd463d6b03e8118d9054bfd1 (diff) |
more subtle bugs found by testing in docker
-rw-r--r-- | Dockerfile | 30 | ||||
-rw-r--r-- | main.go | 29 |
2 files changed, 31 insertions, 28 deletions
diff --git a/Dockerfile b/Dockerfile index d6f1cca..fdfcabc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,18 @@ -FROM alpine:edge +FROM alpine:latest as builder +RUN apk add --update --no-cache curl openssl go && rm -rf /var/cache/apk/* +WORKDIR /app +COPY . ./ -RUN echo -e "\nhttps://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories -RUN apk add --update --no-cache go git make musl-dev curl openssl -RUN mkdir -p /app/src -WORKDIR /app/src -ARG appRoot=/app -COPY appbuild.sh /app/src -RUN chmod +x appbuild.sh -RUN ./appbuild.sh -COPY sign.sh /app/src -WORKDIR / -COPY entrypoint.sh / -RUN chmod +x entrypoint.sh +RUN go mod download +RUN go build + +FROM alpine:latest + + +RUN apk add --update --no-cache curl openssl && rm -rf /var/cache/apk/* +WORKDIR /app +COPY . ./ +COPY --from=builder /app/poseidon /app/poseidon +RUN chmod +x /app/entrypoint.sh EXPOSE 3000 -ENTRYPOINT ./entrypoint.sh +ENTRYPOINT /app/entrypoint.sh diff --git a/main.go b/main.go index e4c7e21..26f8859 100644 --- a/main.go +++ b/main.go @@ -87,7 +87,7 @@ func postFormHandler(w http.ResponseWriter, r *http.Request) { MaxAge: 3600, HttpOnly: true, Secure: true, - SameSite: http.SameSiteStrictMode, + SameSite: http.SameSiteLaxMode, } http.SetCookie(w, &cookie) log.Println(final) @@ -289,6 +289,14 @@ func fetch(fetchurl string, user_agent string, parser_select bool, original *htt } func indexHandler(w http.ResponseWriter, r *http.Request) { + fakeCookie := http.Cookie{ + Name: "blueProxyUserAgent", + Path: "/", + MaxAge: 3600, + HttpOnly: true, + Secure: true, + SameSite: http.SameSiteLaxMode, + } if r.Method == http.MethodPost { http.Error(w, "I am not an owl", http.StatusTeapot) return @@ -383,6 +391,8 @@ func indexHandler(w http.ResponseWriter, r *http.Request) { remurl := urlparts[0] + "//" + urlparts[1] encoded_ua, err := encodeCookie(defaultCookie) + fakeCookie.Value = encoded_ua + if err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) @@ -417,22 +427,13 @@ func indexHandler(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error()+" "+remurl, http.StatusInternalServerError) return } - cookie, err := r.Cookie("blueProxyUserAgent") + var cookie *http.Cookie + cookie, err = r.Cookie("blueProxyUserAgent") if err != nil { switch { case errors.Is(err, http.ErrNoCookie): - cookie := http.Cookie{ - Name: "blueProxyUserAgent", - Value: encoded_ua, - Path: "/", - MaxAge: 3600, - HttpOnly: true, - Secure: true, - SameSite: http.SameSiteLaxMode, - } - http.SetCookie(w, &cookie) - http.Redirect(w, r, r.RequestURI, http.StatusSeeOther) - //http.Error(w, "Try again", http.StatusInternalServerError) + cookie = &fakeCookie + default: log.Println(err) http.Error(w, "server error", http.StatusInternalServerError) |