kubo/test
Lars Gierth 09937f84b6 gateway: enforce allowlist for path prefixes
The gateway accepts an X-Ipfs-Path-Prefix header,
and assumes that it is mounted in a reverse proxy
like nginx, at this path. Links in directory listings,
as well as trailing-slash redirects need to be rewritten
with that prefix in mind.

We don't want a potential attacker to be able to
pass in arbitrary path prefixes, which would end up
in redirects and directory listings, which is why
every prefix has to be explicitly allowed in the config.

Previously, we'd accept *any* X-Ipfs-Path-Prefix header.

Example:

We mount blog.ipfs.io (a dnslink page) at ipfs.io/blog.

nginx_ipfs.conf:

    location /blog/ {
        rewrite "^/blog(/.*)$" $1 break;
        proxy_set_header Host blog.ipfs.io;
        proxy_set_header X-Ipfs-Gateway-Prefix /blog;
        proxy_pass http://127.0.0.1:8080;
    }

.ipfs/config:

    "Gateway": {
        "PathPrefixes": ["/blog"],
        // ...
    },

dnslink:

    > dig TXT _dnslink.blog.ipfs.io
    dnslink=/ipfs/QmWcBjXPAEdhXDATV4ghUpkAonNBbiyFx1VmmHcQe9HEGd

License: MIT
Signed-off-by: Lars Gierth <larsg@systemli.org>
2016-04-04 16:31:57 -04:00
..
3nodetest Rework the Dockerfile 2016-02-04 10:46:26 -08:00
api-startup misc: add test for api readiness 2015-02-15 04:41:18 -08:00
bench config: change default config dir name to .ipfs 2015-04-20 02:25:41 -07:00
bin test/bin: remove ipfs-pin-stat 2016-01-18 21:37:44 +01:00
dependencies clean up dependencies 2016-03-23 11:54:26 -07:00
integration update utp and cleanup more godeps along the way 2016-03-29 19:18:14 -07:00
sharness clean up dependencies 2016-03-23 11:54:26 -07:00
supernode_client gateway: enforce allowlist for path prefixes 2016-04-04 16:31:57 -04:00
.gitignore test: add IPFS-BUILD-OPTIONS to .gitignore 2015-04-06 18:06:24 +02:00
Dockerfile docker: save image space by excluding .git/ 2016-02-05 04:03:30 +01:00
ipfs-test-lib.sh test-lib: add test_path_cmp() 2016-02-12 17:20:23 -08:00
Makefile test/Makefile: add coverage target 2015-10-24 12:34:40 +02:00
README.md test/README: update sharness test coverage 2015-04-02 11:56:49 +02:00
sharness_test_coverage_helper.sh coverage_helper: better group long and short options 2015-10-24 11:22:53 +02:00

Sharness test command coverage

Module Online Test Offline Test
object t0051 t0051
ls t0045 t0045
cat t0040
dht
bitswap
block t0050
daemon t0030 N/A
init N/A t0020
add t0040
config t0021 t0021
version t0060 t0010
ping
diag
mount t0030
name t0110 t0100
pin t0080
get t0090 t0090
refs t0080
repo gc t0080
id
bootstrap t0120 t0120
swarm
update
commands