You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the specification for [compact denlylist format V1](IPIP/383-compact-denylist-format.md).
1
+
---
2
+
title: Compact Denylist Format
3
+
description: >
4
+
How content blocking rules can be represented as a .deny file.
5
+
date: 2023-10-25
6
+
maturity: reliable
7
+
editors:
8
+
- name: Hector Sanjuan
9
+
github: hsanjuan
10
+
affiliation:
11
+
name: Protocol Labs
12
+
url: https://protocol.ai/
13
+
tags: ['filtering']
14
+
order: 1
15
+
---
16
16
17
17
Denylists provide a way to indicate what content should be blocked by IPFS.
18
18
19
-
## Organization of this document
20
-
21
-
-[Introduction](#introduction)
22
-
-[Specification](#specification)
23
-
-[Denylist File extension, locations and order](#denylist-file-extension-locations-and-order)
24
-
-[Denylist format](#denylist-format)
25
-
-[Test fixtures](#test-fixtures)
26
-
-[Security](#security)
27
-
-[Privacy and User Control](#privacy-and-user-control)
28
-
-[Implementations](#implementations)
29
-
30
19
## Introduction
31
20
32
21
A denylist is a collection of items that will be "blocked" on IPFS software.
@@ -55,8 +44,8 @@ done in the future to support specific features.
55
44
The denylist itself, after the header, is a collection of **block items** and
56
45
block-item-specific hints. There are different flavours of block items,
57
46
depending on whether we are blocking by CID, CID+path, Path, IPNS, using
58
-
double-hashing etc. but the idea is that whether an item is blocked or not can
59
-
be decided directly and ideally, prior to retrieval.
47
+
double-hashing etc. but the idea is that whether an item is blocked or not
48
+
SHOULD be decided directly and ideally, _prior to retrieval_.
60
49
61
50
We include *negative block items* as well, with the idea of enabling denylists
62
51
that are append-only. One of the main operational constraints we have seen is
@@ -111,9 +100,9 @@ in future versions.
111
100
112
101
While not pertaining to the denylist format itself, we introduce the following conventions about denylist files when they are stored in the local filesystem:
113
102
114
-
- Denylist files are named with the extension `.deny`.
115
-
- Implementations should look in `/etc/ipfs/denylists/` and
116
-
`$XDG_CONFIG_HOME/ipfs/denylists/` for denylist files.
103
+
- Denylist files MUST be named with the extension `.deny`.
104
+
- Implementations SHOULD look in `/etc/ipfs/denylists/` and
105
+
`$XDG_CONFIG_HOME/ipfs/denylists/`(default: `~/.config/ipfs/denylists`) for denylist files.
117
106
- Denylist files are processed in alphabetical order so that rules from later
118
107
denylists override rules from earlier denylists on conflict.
119
108
@@ -123,7 +112,7 @@ While not pertaining to the denylist format itself, we introduce the following c
123
112
124
113
The following example showcases the features and syntax of a compact denylist:
125
114
126
-
```
115
+
```yaml
127
116
version: 1
128
117
name: IPFSCorp blocking list
129
118
description: A collection of bad things we have found in the universe
@@ -132,7 +121,7 @@ hints:
132
121
hint: value
133
122
hint2: value2
134
123
---
135
-
# Blocking by CID - blocks wrapped multihash.
124
+
# Blocking by CID is codec-agnostic (blocks by multihash).
136
125
# Does not block subpaths per se, but might stop an implementation
137
126
# from resolving subpaths if this block is not retrievable.
A denylist is a UTF-8 encoded text file made of an optional header and a list of blockitems separated by newlines (`\n`). Comment lines start with `#`. Empty lines are allowed.
191
181
192
-
```
193
-
<header>
182
+
```yaml
183
+
[yaml_header]
194
184
---
195
-
<block_item1> [hint_list]
185
+
[block_item1] [optional_hint_list]
196
186
197
187
# comment
198
-
<block_item2> [hint_list]
188
+
[block_item2] [optional_hint_list]
199
189
...
200
190
```
201
191
@@ -240,13 +230,13 @@ should attempt parsing the header as YAML:
240
230
241
231
#### Hints
242
232
243
-
A *hint* is a key-value duple associated to a \<block_item\>. the denylist as
244
-
a whole (part of the header), or to a specific \<block_item\>.
233
+
A *hint* is a key-value duple associated to a `[block_item]`. the denylist as
234
+
a whole (part of the header), or to a specific `[block_item]`.
245
235
246
-
A list of hints can optionally follow every \<block_item\> as show
236
+
A list of hints can optionally follow every `[block_item]` as show
247
237
above. Hints can also be specified in the denylist header ("header
248
238
hints"). This is equivalent to adding the same hints to every single
249
-
\<block_item\> in the denylist. Implementations should associate both the
239
+
`[block_item]` in the denylist. Implementations should associate both the
250
240
specific and the header hints to every block rule.
251
241
252
242
#### List body
@@ -281,8 +271,11 @@ the CID itself.
281
271
Blocking layer recommendation: BlockService (or PathResolver if wanting to
282
272
block by path only).
283
273
284
-
**NOTE**: See note in `/ipfs/CID/*` below, as to why this rule may effectively
285
-
block all subpaths too.
274
+
:::warning
275
+
276
+
See note in `/ipfs/CID/*` below, as to why this rule may effectively block all subpaths too.
277
+
278
+
:::
286
279
287
280
##### `/ipfs/CID/PATH`
288
281
@@ -306,7 +299,9 @@ blocks the CID itself, and any paths. Examples:
306
299
307
300
Blocking layer recommendation: PathResolver
308
301
309
-
**NOTE**: When the rule `/ipfs/CID` exists and BlockService-level blocking
302
+
:::warning
303
+
304
+
When the rule `/ipfs/CID` exists and BlockService-level blocking
310
305
exists, subpaths of CID will effectively be blocked in the process of being
311
306
resolved, as we would disallow fetching the root CID, even if the subpath
312
307
itself is not block. This causes `/ipfs/CID` to behave like
part of the resolution of a subpath that is not blocked. Implementations can
317
312
decide which model they want to adopt.
318
313
314
+
:::
319
315
320
316
##### `/ipns/IPNS`
321
317
@@ -423,6 +419,8 @@ The BlockService should:
423
419
424
420
#### Allow (or negated) rules
425
421
422
+
The specification syntax examples describe a `.deny` list of items to block (deny).
423
+
426
424
Block items can be prepended by `!`, which means that items matching the rule are to be allowed rather than blocked.
427
425
428
426
This can be used to undo existing rules, but also to add concrete exceptions to wider rules. Order matters, and Allow rules must come AFTER other existing rules.
@@ -446,12 +444,19 @@ Examples:
446
444
In this example, `/ipns/my.domain` stays blocked because the deny rule happens
447
445
AFTER the allow one.
448
446
447
+
:::note
448
+
449
+
Implementations MAY reuse denylist format for `.allow` files, where everything
450
+
is blocked by default, and only matching items are allowed.
451
+
452
+
:::
453
+
449
454
#### Hint list
450
455
451
456
A hint list is an optional space-separated list of hints associated with specific block items in the form:
452
457
453
458
```
454
-
<block_item> hintA:v1 hintB:v2 hintC:v3
459
+
[block_item] hintA:v1 hintB:v2 hintC:v3
455
460
```
456
461
457
462
Block items and hints are separated by one or more consecutive instances of
@@ -464,7 +469,7 @@ Denylist parsing and correct behaviour can be tested using the
464
469
denylist, which provides example rules and describes the expected behaviour in
465
470
detail.
466
471
467
-
In particular, a [Blocker implementation validator](https://github.com/ipfs-shipyard/nopfs/tree/master/tester) is provided in Go, and can be adapted to other languages if needed.
472
+
In particular, a reference [Blocker implementation validator](https://github.com/ipfs-shipyard/nopfs/tree/master/tester) is provided in Go, and can be adapted to other languages if needed.
Copy file name to clipboardExpand all lines: src/ipips/ipip-0383.md
+25-12Lines changed: 25 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,28 @@
1
-
# IPIP-383: Compact denylist format
2
-
3
-
- Start Date: 2023-03-09
4
-
- Related Issues:
5
-
- A different proposal: https://github.com/ipfs/specs/pull/340
1
+
---
2
+
title: "IPIP-0383: Compact Denylist Format"
3
+
date: 2023-03-09
4
+
ipip: proposal
5
+
editors:
6
+
- name: Hector Sanjuan
7
+
github: hsanjuan
8
+
affiliation:
9
+
name: Protocol Labs
10
+
url: https://protocol.ai/
11
+
relatedIssues:
12
+
- https://github.com/ipfs/specs/issues/298
13
+
- https://github.com/ipfs/specs/pull/299
14
+
- https://github.com/ipfs/specs/pull/340
15
+
order: 383
16
+
tags: ['ipips']
17
+
---
6
18
7
19
## Summary
8
20
9
21
This IPIP introduces a line-based denylist format for content blocking on IPFS
10
22
focused on simplicity, scalability and ease-of-use.
11
23
12
-
A reference Go implementation of a denylist parser and Blocker component for the Go-IPFS stack exists at https://github.com/ipfs-shipyard/nopfs.
24
+
A reference Go implementation of a denylist parser and Blocker component for
25
+
the Kubo (go-ipfs) stack exists at https://github.com/ipfs-shipyard/nopfs.
13
26
14
27
## Motivation
15
28
@@ -23,7 +36,7 @@ can rely on and share.
23
36
24
37
## Detailed design
25
38
26
-
See [Compact Denylist Format](../COMPACT_DENYLIST_FORMAT.md).
39
+
See :cite[compact-denylist-format].
27
40
28
41
## Design rationale
29
42
@@ -51,7 +64,7 @@ The proposed design is part of a holistic approach to content-moderation for IPF
51
64
- Ability to block based on CID codec (only allow Codec X)
52
65
- Ability to block based on multihash function (”no identity multihashes”)
53
66
- Ability to block IPNS names
54
-
67
+
55
68
- Regarding the lists:
56
69
- Compact format, compression friendly
57
70
- Line-based so that updates can be watched
@@ -66,7 +79,7 @@ The proposed design is part of a holistic approach to content-moderation for IPF
66
79
- Lists support gateway http error hints (i.e. type of block)
67
80
-`echo "/ipfs/cid" >> ~/.config/ipfs/denylists/custom` should work
68
81
- Lists have a header section with information about the list.
69
-
82
+
70
83
- Regarding the implementation:
71
84
- Multiple denylists should be supported
72
85
- Hot-reloading of list (no restart of IPFS required)
@@ -96,9 +109,9 @@ Users and developers will benefit from a list format that is easy to work with b
96
109
97
110
### Compatibility
98
111
99
-
The current Protocol Labs denylist format
100
-
https://badbits.dwebops.pub/denylist.json can be easily converted into the
101
-
proposed compact format. This is shown at https://badbits.dwebops.pub/badbits.deny.
112
+
The old JSON-based Protocol Labs denylist format
113
+
[https://badbits.dwebops.pub/denylist.json](https://web.archive.org/web/20230610082307/https://badbits.dwebops.pub/denylist.json) can be easily converted into the
114
+
proposed compact format. This is shown at <https://badbits.dwebops.pub/badbits.deny>.
0 commit comments