Git Product home page Git Product logo

rawgithack's Introduction

raw.githack.com

This is the source code behind raw.githack.com - CDN for your source code that serves files with proper Content-Type headers.

Example config.lua

return {
   simsim = "SECRET",
   cf = {
      zone = "ZONE_ID",
      username = "USERNAME",
      api_key = "API_KEY",
      username = "USERNAME"
   },
   patreon = {
      campaign = "CAMPAIGN_ID",
      token = "ACCESS_TOKEN"
   }
}

Frontend

Pages are built using jopa static site generator, with the following command:

layout_file="web/layout.jsh" from="web/pages" jopa

rawgithack's People

Contributors

artoria2e5 avatar dlenski avatar jcoleman avatar kasbah avatar maomihz avatar mathieu-aubin avatar nabijaczleweli avatar neoascetic avatar richienb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rawgithack's Issues

cross site spoofing with localStorage between 2 repos

If a Github Pages repo, is accessed through githack, in many cases a website will render and operate as intended locating all resources through githack instead of Github/Fastly, the user must visually ignore the address bar, but localStorage, ummm, origin will be "rawcdn.githack.com" and localStorage contents can easily be fetched later with a malicious github pages repo to the sensitive github pages repo running on wrong origin. Not sure if there is a real bug since github pages shouldn't have a concept of "logging in", but some GH pages sites do "login" with localStorage. Feel free to close if there is no quick fix.

I've used githack as a quick and dirty different "origin" for a GH Pages site when a CORS API WAF got tired of my no API key anonymous usage and punishes my Origin: header by omitting "Access-Control-Allow-Credentials: true" in response for some minutes to my Origin: header and I burned through the official domain and "http://localhost" already. file:// doesn't work as that makes a browser send "Origin: null" for XHR CORS.

Feature request: Support for googlesource.com-hosted repos (Chromium, Android, PDFium, ...)

Example URLs:

https://android.googlesource.com/platform/external/linux-tools-perf/+/jb-dev/Documentation/perf-script.txt
https://pdfium.googlesource.com/pdfium.git/+/dab1161c861cc239e48a17e1a5d729aa12785a53/core/fdrm/fx_crypt.cpp
https://chromium.googlesource.com/chromium/src.git/+/c15858db55ed54c230743eaa9678117f21d5517e/third_party/blink/renderer/core/svg/svg_point.cc

I have a web app in which I would like to display source code from these repos. However, googlesource.com (Gitiles) does not have a way to serve raw source with CORS headers. In fact, it does not have a way to serve raw unencoded source code at all! It only supports base64-encoded source code, but without CORS headers:

https://android.googlesource.com/platform/external/linux-tools-perf/+/jb-dev/Documentation/perf-script.txt?format=TEXT

There has been a long-standing feature request in the Gitiles issue tracker about this (original request (filed in 2012), migrated issue) and you can see many people complaining that they have to work around this limitation, but no progress has been made.

If rawgithack supported these repos, this would be an excellent workaround.

Re-direct results in not being able to bypass CORS

I am not sure bypassing gitlabs CORS policy on artifacts is one of the goals of this project but I would find that really handy. It currently works for most artifacts but not when you are trying to use re-directs.

https://glcdn.githack.com/openflexure/openflexure-microscope/-/jobs/artifacts/master/raw/builds/main_body_LS65.stl?job=STLs

re-directs to

https://gitlab.com/openflexure/openflexure-microscope/-/jobs/223115318/artifacts/raw/builds/main_body_LS65.stl

so when I try and use URLs like that that grab the latest artifacts from the master branch I get CORS errors.

Nowhere to donate 💰

BIG ISSUE!!

Was looking around and couldn't find anywhere to donate 😟
How is the community supposed to help out with the server fees!?

Like I said, this is a serious issue. You should add a donate button somewhere.

lua_load_resty_core failed when running locally

Not sure if it's a problem or not but running locally on Ubuntu 16.04 with

docker build -t rawgithack .
docker run -p 80:80 rawgithack

Reports error:

2019/06/01 15:23:41 [error] 1#1: lua_load_resty_core failed to load the resty.core module from https://github.com/openresty/lua-resty-core; ensure you are using an OpenResty release from https://openresty.org/en/download.html (rc: 2, reason: module 'resty.core' not found:
	no field package.preload['resty.core']
	no file '/etc/nginx/rawgithack/resty/core.lua'
	no file '/usr/local/openresty/site/lualib/resty/core.so'
	no file '/usr/local/openresty/lualib/resty/core.so'
	no file './resty/core.so'
	no file '/usr/local/lib/lua/5.1/resty/core.so'
	no file '/usr/local/openresty/luajit/lib/lua/5.1/resty/core.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
	no file '/usr/local/openresty/site/lualib/resty.so'
	no file '/usr/local/openresty/lualib/resty.so'
	no file './resty.so'
	no file '/usr/local/lib/lua/5.1/resty.so'
	no file '/usr/local/openresty/luajit/lib/lua/5.1/resty.so'
	no file '/usr/local/lib/lua/5.1/loadall.so')
nginx: [error] lua_load_resty_core failed to load the resty.core module from https://github.com/openresty/lua-resty-core; ensure you are using an OpenResty release from https://openresty.org/en/download.html (rc: 2, reason: module 'resty.core' not found:
	no field package.preload['resty.core']
	no file '/etc/nginx/rawgithack/resty/core.lua'
	no file '/usr/local/openresty/site/lualib/resty/core.so'
	no file '/usr/local/openresty/lualib/resty/core.so'
	no file './resty/core.so'
	no file '/usr/local/lib/lua/5.1/resty/core.so'
	no file '/usr/local/openresty/luajit/lib/lua/5.1/resty/core.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
	no file '/usr/local/openresty/site/lualib/resty.so'
	no file '/usr/local/openresty/lualib/resty.so'
	no file './resty.so'
	no file '/usr/local/lib/lua/5.1/resty.so'
	no file '/usr/local/openresty/luajit/lib/lua/5.1/resty.so'
	no file '/usr/local/lib/lua/5.1/loadall.so')

EDIT: Seems to work ok though? If I add this to /etc/hosts, I can see the rawgit page and can see a GET request logged locally.

127.0.0.1 raw.githack.com

By the way, also tried to add:

127.0.0.1 gl.githack.com

But that doesn't seem enough to test the proxy locally.

Reduce Caching To 2 Hours

The website states that results are cached for "1 year" which is excessive. Cache hits follow a zipf distribution, the general rule-of-thumb for TTL : cache hit rate is (very roughly) 15 minutes : 85%, 1 hour : 95% and 24 hours : 97%. The Cloudflare cache also respects ETags, so you shouldn't need to do a lot of processing.

You have a unique set of customers so YMMV, but it couldn't hurt to experiment. I would drop the browser-side cache to 15 minutes or an hour and just report Cloudflare's standard 2-hour cache.

HTTP proto

Because of "Mixed content" limitations with the browser fetch API / xmlHttpRequest,
scripts that send requests to http:// are not working.. So, should it be enabled?

Enable cache purge by URL

The CloudFlare API allows you to purge individual files. The CDN would be much more useful if we could purge certain files on demand. The simplest option would be to setup a site that allows people to just submit a URL for purging and rate limit based on IP address.

Support git lfs

It seems githack.com does not work with git lfs. Here's a test repo (not mine) with an LFS file: https://github.com/Schoonology/git-lfs-test - the file binary.jpg is stored with LFS. If I understand how githack is supposed to work, I should be able to wget that file straight from githack.com:

wget https://raw.githack.com/Schoonology/git-lfs-test/master/binary.jpg

But that just returns the pointer file:

% head binary.jpg
version https://git-lfs.github.com/spec/v1
oid sha256:6fe2e48ef494b7855e6d8f93c59cf38d38350274e304a9ac35102d5c365ee002
size 620773

which is not good.

Downloading straight from github raw works fine:

% wget https://github.com/Schoonology/git-lfs-test/raw/master/binary.jpg
% file binary.jpg.2
binary.jpg.2: JPEG image data, JFIF standard 1.01

but downloading using raw.githubusercontent.com (which may be where githack.com is proxying from?) does not:

% wget https://raw.githubusercontent.com/Schoonology/git-lfs-test/master/binary.jpg 
% file binary.jpg.3
binary.jpg.3: ASCII text

So it would appear that at this point, githack doesn't support LFS. It would be great if it could!

CDN for Bitbucket / Gitlab doesn't support partial request (Range header)

I'm trying to stream audio files, which requires the request to support partial response by specifying the "Range: " header.

Partial request should already be supported by Cloudflare, and it works for Github (rawcdn.githack.com, gistcdn.githack.com). However I found that both Bitbucket (bbcdn.githack.com) and Gitlab (glcdn.githack.com) does not support partial response.

In this case Content-Type doesn't matter, it still works if the content-type is application/octet-stream instead of audio/x-m4a, as long as partial request is supported.

Is that an intentional behaviour or configuration problem?

Test for Github CDN, which returns 206 Partial Content:

curl --header 'Range: bytes=0-10' -v -o /dev/null 'https://gistcdn.githack.com/arcnavier/725bc575222fe8e9931618c2d5b6580f/raw/Lovely%20Day%20-%20Most%20Beautiful%20Anime%20Music%20%281%20Hour%20BGM%29.m4a'

  Trying 104.31.95.240...
* TCP_NODELAY set
* Connected to gistcdn.githack.com (104.31.95.240) port 443 (#0)
...
< HTTP/2 206 
< date: Thu, 19 Apr 2018 13:17:43 GMT
< content-type: application/octet-stream
< content-length: 11
...
< cf-cache-status: HIT
< content-range: bytes 0-10/57847658
< server: cloudflare
< 
{ [11 bytes data]

Test for Gitlab CDN, returns 200 with the entire content

curl --header 'Range: bytes=0-10' -v -o /dev/null 'https://glcdn.githack.com/maomihz/bigmusic/raw/master/2 Hour Beautiful Piano Music - Romantic Love Song 【BGM】.m4a'

  Trying 104.31.94.240...
* TCP_NODELAY set
* Connected to glcdn.githack.com (104.31.94.240) port 443 (#0)
...
< HTTP/2 200 
< date: Thu, 19 Apr 2018 13:17:23 GMT
< content-type: application/octet-stream
< content-length: 114571793
...
< cf-cache-status: HIT
< server: cloudflare
< cf-ray: 40dfa6afbec5586d-DFW
< 
{ [783 bytes data]

Bitbucket, returns 200

curl --header 'Range: bytes=0-10' -v -o /dev/null 'https://bbcdn.githack.com/pypy/pypy/raw/51718fe91a11a641de8dfd2e54a7df4876ceca20/get_externals.py'

  Trying 104.31.94.240...
* TCP_NODELAY set
* Connected to bbcdn.githack.com (104.31.94.240) port 443 (#0)

< HTTP/2 200 
< date: Thu, 19 Apr 2018 13:33:45 GMT
< content-type: text/plain

Thank you for your effort!

How to run locally?

Hey this is an awesome repo! especially now that rawgit.com is going away.

I was trying to run this repo locally:

docker build -t rawgithack .
docker run -p 8080:80 rawgithack &
[1] 70585
docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
7742acb7107c        rawgithack          "nginx -g 'daemon of…"   3 seconds ago       Up 2 seconds        0.0.0.0:8080->80/tcp   gracious_lovelace

Then I see this at localhost:8080:

screen shot 2018-10-26 at 2 19 28 pm

But how do test it out locally?

Thanks!

Support Gitlab CI artifacts

As discussed in #39 and #40 Gitlab CI artifacts currently, kind of work, so much that I assumed they were supported. But:

  1. Using git ref urls that re-direct to specific job artifacts ends up re-directing to gitlab.com. This is a more general issue and tracked as #41

https://glcdn.githack.com/openflexure/openflexure-microscope/-/jobs/artifacts/master/raw/builds/main_body_LS65.stl?job=STLs

re-directs to

https://gitlab.com/openflexure/openflexure-microscope/-/jobs/223115318/artifacts/raw/builds/main_body_LS65.stl

so when I try and use URLs like that that grab the latest artifacts from the master branch I get CORS errors.

  1. Query parameters are not supported by the cache and the frontend utility that tells you what the URLs are but:

https://gl.githack.com/openflexure/openflexure-microscope/-/jobs/artifacts/master/raw/builds/main_body_LS65.stl serves a 404 and https://gl.githack.com/openflexure/openflexure-microscope/-/jobs/artifacts/master/raw/builds/main_body_LS65.stl?job=STLs serves the file :/

This could maybe be a more general issue around supporting query parameters?

Are there any other potential issues with supporting Gitlab CI artifacts that haven't been mentioned yet?

CSS minification breaks CSS

Example code:

/* Checkboxes and radios share much of the same code. */
@import './input.shared.css';

input[type='checkbox' i] {
	/* Checkboxes are boxes with rounded corners. */
	--checkable-border-radius: 15%;
}

input[type='checkbox' i]:before {
	border-top: none;
	border-left: none;
	border-radius: 0;
	background: none;
	height: calc(var(--checkable-mark-scale) * 55%);
	width: calc(var(--checkable-mark-scale) * 28%);
}

Output example:

@import './input.shared.css';input[type=checkboxi]{--checkable-border-radius: 15%}input[type=checkboxi]:before{border-top:none;border-left:none;border-radius:0;background:0 0;height:calc(var(--checkable-mark-scale) * 55%);width:calc(var(--checkable-mark-scale) * 28%)}

URL: https://rawcdn.githack.com/lume/basicss/1a2352cf30c07494ede015bb13b6e81bd26c4f9a/src/elements/input/input-checkbox.css

Notice the i values inside the attribute selectors have been squashed onto the attribute values. The CSS no longer works when this happens.

webpage keeps cycling through all urls; can't purge old ones

Hello,

Testing out some personal webpage stuff and I'm running into this issue:

  • My webpage keeps cycling through all of the previous links to a particular page, and when I try to purge the link via your site, it keeps saying "too many requests".
  • Also, it does not appear that the links are being purged (when it allegedly does successfully purge it), as they keep popping back up in the rotation.

Am I doing something wrong? Please let me know what you think.

Gitlab support is broken?

Is the support for Gitlab complete?

I pasted this random link (as an example) https://gitlab.com/dankremniov/holiday-confession/blob/900c112f5673b247830ec88d829011cfa4a5da62/build/images/backgrounds/1.jpg and the site generates the CDN hosted version as https://glcdn.githack.com/dankremniov/holiday-confession/raw/900c112f5673b247830ec88d829011cfa4a5da62/build/images/backgrounds/1.jpg.

However, that link simply redirects back to gitlab as seen below.

$ curl -I "https://glcdn.githack.com/dankremniov/holiday-confession/raw/900c112f5673b247830ec88d829011cfa4a5da62/build/images/backgrounds/1.jpg"
HTTP/1.1 301 Moved Permanently
Date: Tue, 08 Nov 2016 08:59:12 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Set-Cookie: __cfduid=df5855d81064f688ac6fd7077fd2177b01478595552; expires=Wed, 08-Nov-17 08:59:12 GMT; path=/; domain=.githack.com; HttpOnly
Location: https://gitlab.com/dankremniov/holiday-confession/raw/900c112f5673b247830ec88d829011cfa4a5da62/build/images/backgrounds/1.jpg
CF-Cache-Status: MISS
Expires: Wed, 08 Nov 2017 08:59:12 GMT
Cache-Control: public, max-age=31536000
Server: cloudflare-nginx
CF-RAY: 2fe7d3dbbeca31b0-SIN

Redirect loop after requesting a URL with a double slash

This URL responds with a redirect loop: https://rawcdn.githack.com/rust-lang/rust/88f19c6dab716c6281af7602e30f413e809c5974/library/std/src/sys/windows/thread.rs

This happened after I initially opened it with an extra slash (note the double slash before library): https://rawcdn.githack.com/rust-lang/rust/88f19c6dab716c6281af7602e30f413e809c5974//library/std/src/sys/windows/thread.rs

It seems that some bad state is cached.

I can reproduce this with arbitrary other URLs, if the initial request to them contains the extra slash. Once the bad state is cached, the URL is "poisoned". For example, I confirmed this with https://rawcdn.githack.com/rust-lang/rust/88f19c6dab716c6281af7602e30f413e809c5974/library/std/src/sys/unix/alloc.rs .

raw.githack.com Favicon

Hi neoascetic,

Do you think it's possible to add a Favicon ?
I made little hack to reuse rawgit.com Favicon to identify you webapp ;)

If use full path to get the image :

<link rel="icon" href="/path/to/favicon.png">

image

sushi

Maybe you want to add your own custom Icon ;)

I take advantage to thank you for your githack.com service.

Best regards,
Nicolas D.

A way to invalidate the cache?

First off, thanks for running this...

I'd like to be able to offer 'latest'-tag functionality for accessing a gitlab-hosted JS file. I'm updating my 'latest' tag whenever I update this file. But of course, your CDN will cache that record for a year. Is there a way to send a parameter to CDN that invalidates the rawcdn entry with the new file?

Raw githack for GitLab is down today?

I just found that raw.githack.com for gitlab is down today...

Please check, my url is

https://glcdn.githack.com/imgfo/example/-/raw/master/imgfo/example-api-1.17.1.json

Screenshot from 2021-03-27 05-59-41

generate integrity code

When i enter a script file then i would want something like cdnjs gives you

	<script
		src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.1.0/papaparse.min.js"
		integrity="sha256-Fh801SO9gqegfUdkDxyzXzIUPWzO/Vatqj8uN+5xcL4="
		crossorigin="anonymous"
	></script>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.