@push.rocks/smartnftables 1.2.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +37 -0
- package/dist_rust/smartnftables_linux_amd64_musl +0 -0
- package/dist_rust/smartnftables_linux_amd64_musl.tsrust-build.json +14 -0
- package/dist_rust/smartnftables_linux_arm64_musl +0 -0
- package/dist_rust/smartnftables_linux_arm64_musl.tsrust-build.json +14 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.managednftables.d.ts +21 -0
- package/dist_ts/classes.managednftables.js +182 -0
- package/dist_ts/index.d.ts +2 -0
- package/dist_ts/index.js +2 -1
- package/dist_ts/managed.types.d.ts +103 -0
- package/dist_ts/managed.types.js +2 -0
- package/dist_ts/plugins.d.ts +5 -2
- package/dist_ts/plugins.js +6 -3
- package/native-notices/crates/block-buffer-0.10.4/license-apache +201 -0
- package/native-notices/crates/block-buffer-0.10.4/license-mit +25 -0
- package/native-notices/crates/cfg-if-1.0.4/license-apache +201 -0
- package/native-notices/crates/cfg-if-1.0.4/license-mit +25 -0
- package/native-notices/crates/cpufeatures-0.2.17/license-apache +201 -0
- package/native-notices/crates/cpufeatures-0.2.17/license-mit +25 -0
- package/native-notices/crates/crypto-common-0.1.7/license-apache +201 -0
- package/native-notices/crates/crypto-common-0.1.7/license-mit +25 -0
- package/native-notices/crates/digest-0.10.7/license-apache +201 -0
- package/native-notices/crates/digest-0.10.7/license-mit +25 -0
- package/native-notices/crates/generic-array-0.14.7/license +21 -0
- package/native-notices/crates/itoa-1.0.18/license-apache +176 -0
- package/native-notices/crates/itoa-1.0.18/license-mit +23 -0
- package/native-notices/crates/libc-0.2.189/license-apache +176 -0
- package/native-notices/crates/libc-0.2.189/license-mit +25 -0
- package/native-notices/crates/memchr-2.8.3/copying +3 -0
- package/native-notices/crates/memchr-2.8.3/license-mit +21 -0
- package/native-notices/crates/proc-macro2-1.0.107/license-apache +176 -0
- package/native-notices/crates/proc-macro2-1.0.107/license-mit +23 -0
- package/native-notices/crates/quote-1.0.47/license-apache +176 -0
- package/native-notices/crates/quote-1.0.47/license-mit +23 -0
- package/native-notices/crates/serde-1.0.229/license-apache +176 -0
- package/native-notices/crates/serde-1.0.229/license-mit +23 -0
- package/native-notices/crates/serde_core-1.0.229/license-apache +176 -0
- package/native-notices/crates/serde_core-1.0.229/license-mit +23 -0
- package/native-notices/crates/serde_derive-1.0.229/license-apache +176 -0
- package/native-notices/crates/serde_derive-1.0.229/license-mit +23 -0
- package/native-notices/crates/serde_json-1.0.151/license-apache +176 -0
- package/native-notices/crates/serde_json-1.0.151/license-mit +23 -0
- package/native-notices/crates/sha2-0.10.9/license-apache +201 -0
- package/native-notices/crates/sha2-0.10.9/license-mit +27 -0
- package/native-notices/crates/syn-3.0.5/license-apache +176 -0
- package/native-notices/crates/syn-3.0.5/license-mit +23 -0
- package/native-notices/crates/typenum-1.20.1/license +1 -0
- package/native-notices/crates/typenum-1.20.1/license-apache +201 -0
- package/native-notices/crates/typenum-1.20.1/license-mit +21 -0
- package/native-notices/crates/unicode-ident-1.0.24/license-apache +176 -0
- package/native-notices/crates/unicode-ident-1.0.24/license-mit +23 -0
- package/native-notices/crates/unicode-ident-1.0.24/license-unicode +39 -0
- package/native-notices/crates/version_check-0.9.5/license-apache +201 -0
- package/native-notices/crates/version_check-0.9.5/license-mit +19 -0
- package/native-notices/crates/zmij-1.0.23/license-mit +23 -0
- package/native-notices/manifest.json +520 -0
- package/native-notices/readme.md +36 -0
- package/native-notices/rust-standard-library/addr2line-0.25.1-license-apache +201 -0
- package/native-notices/rust-standard-library/addr2line-0.25.1-license-mit +25 -0
- package/native-notices/rust-standard-library/cargo.lock +522 -0
- package/native-notices/rust-standard-library/compiler-builtins-license.txt +275 -0
- package/native-notices/rust-standard-library/dependency-notices.html +9072 -0
- package/native-notices/rust-standard-library/license-apache +176 -0
- package/native-notices/rust-standard-library/license-mit +25 -0
- package/native-notices/rust-standard-library/llvm-libunwind-license.txt +311 -0
- package/native-notices/rust-standard-library/musl-1.2.5-copyright.txt +193 -0
- package/native-notices/rust-standard-library/unicode-license.txt +39 -0
- package/package.json +23 -8
- package/readme.md +160 -2
- package/rust/.cargo/config.toml +2 -0
- package/rust/Cargo.lock +192 -0
- package/rust/Cargo.toml +13 -0
- package/rust/src/main.rs +159 -0
- package/rust/src/namespace.rs +51 -0
- package/rust/src/owner.rs +604 -0
- package/rust/src/owner_namespace_tests.rs +242 -0
- package/rust/src/owner_tests.rs +798 -0
- package/rust/src/policy.rs +427 -0
- package/rust/src/tests.rs +97 -0
- package/rust/src/wire.rs +437 -0
- package/scripts/check-native-notices.mjs +27 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.managednftables.ts +153 -0
- package/ts/index.ts +2 -0
- package/ts/managed.types.ts +91 -0
- package/ts/plugins.ts +6 -0
- /package/{license → license.md} +0 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
musl as a whole is licensed under the following standard MIT license:
|
|
2
|
+
|
|
3
|
+
----------------------------------------------------------------------
|
|
4
|
+
Copyright © 2005-2020 Rich Felker, et al.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
a copy of this software and associated documentation files (the
|
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
12
|
+
the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
20
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
21
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
22
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
23
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
----------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
Authors/contributors include:
|
|
27
|
+
|
|
28
|
+
A. Wilcox
|
|
29
|
+
Ada Worcester
|
|
30
|
+
Alex Dowad
|
|
31
|
+
Alex Suykov
|
|
32
|
+
Alexander Monakov
|
|
33
|
+
Andre McCurdy
|
|
34
|
+
Andrew Kelley
|
|
35
|
+
Anthony G. Basile
|
|
36
|
+
Aric Belsito
|
|
37
|
+
Arvid Picciani
|
|
38
|
+
Bartosz Brachaczek
|
|
39
|
+
Benjamin Peterson
|
|
40
|
+
Bobby Bingham
|
|
41
|
+
Boris Brezillon
|
|
42
|
+
Brent Cook
|
|
43
|
+
Chris Spiegel
|
|
44
|
+
Clément Vasseur
|
|
45
|
+
Daniel Micay
|
|
46
|
+
Daniel Sabogal
|
|
47
|
+
Daurnimator
|
|
48
|
+
David Carlier
|
|
49
|
+
David Edelsohn
|
|
50
|
+
Denys Vlasenko
|
|
51
|
+
Dmitry Ivanov
|
|
52
|
+
Dmitry V. Levin
|
|
53
|
+
Drew DeVault
|
|
54
|
+
Emil Renner Berthing
|
|
55
|
+
Fangrui Song
|
|
56
|
+
Felix Fietkau
|
|
57
|
+
Felix Janda
|
|
58
|
+
Gianluca Anzolin
|
|
59
|
+
Hauke Mehrtens
|
|
60
|
+
He X
|
|
61
|
+
Hiltjo Posthuma
|
|
62
|
+
Isaac Dunham
|
|
63
|
+
Jaydeep Patil
|
|
64
|
+
Jens Gustedt
|
|
65
|
+
Jeremy Huntwork
|
|
66
|
+
Jo-Philipp Wich
|
|
67
|
+
Joakim Sindholt
|
|
68
|
+
John Spencer
|
|
69
|
+
Julien Ramseier
|
|
70
|
+
Justin Cormack
|
|
71
|
+
Kaarle Ritvanen
|
|
72
|
+
Khem Raj
|
|
73
|
+
Kylie McClain
|
|
74
|
+
Leah Neukirchen
|
|
75
|
+
Luca Barbato
|
|
76
|
+
Luka Perkov
|
|
77
|
+
M Farkas-Dyck (Strake)
|
|
78
|
+
Mahesh Bodapati
|
|
79
|
+
Markus Wichmann
|
|
80
|
+
Masanori Ogino
|
|
81
|
+
Michael Clark
|
|
82
|
+
Michael Forney
|
|
83
|
+
Mikhail Kremnyov
|
|
84
|
+
Natanael Copa
|
|
85
|
+
Nicholas J. Kain
|
|
86
|
+
orc
|
|
87
|
+
Pascal Cuoq
|
|
88
|
+
Patrick Oppenlander
|
|
89
|
+
Petr Hosek
|
|
90
|
+
Petr Skocik
|
|
91
|
+
Pierre Carrier
|
|
92
|
+
Reini Urban
|
|
93
|
+
Rich Felker
|
|
94
|
+
Richard Pennington
|
|
95
|
+
Ryan Fairfax
|
|
96
|
+
Samuel Holland
|
|
97
|
+
Segev Finer
|
|
98
|
+
Shiz
|
|
99
|
+
sin
|
|
100
|
+
Solar Designer
|
|
101
|
+
Stefan Kristiansson
|
|
102
|
+
Stefan O'Rear
|
|
103
|
+
Szabolcs Nagy
|
|
104
|
+
Timo Teräs
|
|
105
|
+
Trutz Behn
|
|
106
|
+
Valentin Ochs
|
|
107
|
+
Will Dietz
|
|
108
|
+
William Haddon
|
|
109
|
+
William Pitcock
|
|
110
|
+
|
|
111
|
+
Portions of this software are derived from third-party works licensed
|
|
112
|
+
under terms compatible with the above MIT license:
|
|
113
|
+
|
|
114
|
+
The TRE regular expression implementation (src/regex/reg* and
|
|
115
|
+
src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed
|
|
116
|
+
under a 2-clause BSD license (license text in the source files). The
|
|
117
|
+
included version has been heavily modified by Rich Felker in 2012, in
|
|
118
|
+
the interests of size, simplicity, and namespace cleanliness.
|
|
119
|
+
|
|
120
|
+
Much of the math library code (src/math/* and src/complex/*) is
|
|
121
|
+
Copyright © 1993,2004 Sun Microsystems or
|
|
122
|
+
Copyright © 2003-2011 David Schultz or
|
|
123
|
+
Copyright © 2003-2009 Steven G. Kargl or
|
|
124
|
+
Copyright © 2003-2009 Bruce D. Evans or
|
|
125
|
+
Copyright © 2008 Stephen L. Moshier or
|
|
126
|
+
Copyright © 2017-2018 Arm Limited
|
|
127
|
+
and labelled as such in comments in the individual source files. All
|
|
128
|
+
have been licensed under extremely permissive terms.
|
|
129
|
+
|
|
130
|
+
The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008
|
|
131
|
+
The Android Open Source Project and is licensed under a two-clause BSD
|
|
132
|
+
license. It was taken from Bionic libc, used on Android.
|
|
133
|
+
|
|
134
|
+
The AArch64 memcpy and memset code (src/string/aarch64/*) are
|
|
135
|
+
Copyright © 1999-2019, Arm Limited.
|
|
136
|
+
|
|
137
|
+
The implementation of DES for crypt (src/crypt/crypt_des.c) is
|
|
138
|
+
Copyright © 1994 David Burren. It is licensed under a BSD license.
|
|
139
|
+
|
|
140
|
+
The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was
|
|
141
|
+
originally written by Solar Designer and placed into the public
|
|
142
|
+
domain. The code also comes with a fallback permissive license for use
|
|
143
|
+
in jurisdictions that may not recognize the public domain.
|
|
144
|
+
|
|
145
|
+
The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011
|
|
146
|
+
Valentin Ochs and is licensed under an MIT-style license.
|
|
147
|
+
|
|
148
|
+
The x86_64 port was written by Nicholas J. Kain and is licensed under
|
|
149
|
+
the standard MIT terms.
|
|
150
|
+
|
|
151
|
+
The mips and microblaze ports were originally written by Richard
|
|
152
|
+
Pennington for use in the ellcc project. The original code was adapted
|
|
153
|
+
by Rich Felker for build system and code conventions during upstream
|
|
154
|
+
integration. It is licensed under the standard MIT terms.
|
|
155
|
+
|
|
156
|
+
The mips64 port was contributed by Imagination Technologies and is
|
|
157
|
+
licensed under the standard MIT terms.
|
|
158
|
+
|
|
159
|
+
The powerpc port was also originally written by Richard Pennington,
|
|
160
|
+
and later supplemented and integrated by John Spencer. It is licensed
|
|
161
|
+
under the standard MIT terms.
|
|
162
|
+
|
|
163
|
+
All other files which have no copyright comments are original works
|
|
164
|
+
produced specifically for use as part of this library, written either
|
|
165
|
+
by Rich Felker, the main author of the library, or by one or more
|
|
166
|
+
contibutors listed above. Details on authorship of individual files
|
|
167
|
+
can be found in the git version control history of the project. The
|
|
168
|
+
omission of copyright and license comments in each file is in the
|
|
169
|
+
interest of source tree size.
|
|
170
|
+
|
|
171
|
+
In addition, permission is hereby granted for all public header files
|
|
172
|
+
(include/* and arch/*/bits/*) and crt files intended to be linked into
|
|
173
|
+
applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit
|
|
174
|
+
the copyright notice and permission notice otherwise required by the
|
|
175
|
+
license, and to use these files without any requirement of
|
|
176
|
+
attribution. These files include substantial contributions from:
|
|
177
|
+
|
|
178
|
+
Bobby Bingham
|
|
179
|
+
John Spencer
|
|
180
|
+
Nicholas J. Kain
|
|
181
|
+
Rich Felker
|
|
182
|
+
Richard Pennington
|
|
183
|
+
Stefan Kristiansson
|
|
184
|
+
Szabolcs Nagy
|
|
185
|
+
|
|
186
|
+
all of whom have explicitly granted such permission.
|
|
187
|
+
|
|
188
|
+
This file previously contained text expressing a belief that most of
|
|
189
|
+
the files covered by the above exception were sufficiently trivial not
|
|
190
|
+
to be subject to copyright, resulting in confusion over whether it
|
|
191
|
+
negated the permissions granted in the license. In the spirit of
|
|
192
|
+
permissive licensing, and of not having licensing issues being an
|
|
193
|
+
obstacle to adoption, that text has been removed.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
UNICODE LICENSE V3
|
|
2
|
+
|
|
3
|
+
COPYRIGHT AND PERMISSION NOTICE
|
|
4
|
+
|
|
5
|
+
Copyright © 1991-2026 Unicode, Inc.
|
|
6
|
+
|
|
7
|
+
NOTICE TO USER: Carefully read the following legal agreement. BY
|
|
8
|
+
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
|
|
9
|
+
SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
|
|
10
|
+
TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
|
|
11
|
+
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
14
|
+
copy of data files and any associated documentation (the "Data Files") or
|
|
15
|
+
software and any associated documentation (the "Software") to deal in the
|
|
16
|
+
Data Files or Software without restriction, including without limitation
|
|
17
|
+
the rights to use, copy, modify, merge, publish, distribute, and/or sell
|
|
18
|
+
copies of the Data Files or Software, and to permit persons to whom the
|
|
19
|
+
Data Files or Software are furnished to do so, provided that either (a)
|
|
20
|
+
this copyright and permission notice appear with all copies of the Data
|
|
21
|
+
Files or Software, or (b) this copyright and permission notice appear in
|
|
22
|
+
associated Documentation.
|
|
23
|
+
|
|
24
|
+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
|
25
|
+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
26
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
27
|
+
THIRD PARTY RIGHTS.
|
|
28
|
+
|
|
29
|
+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
|
|
30
|
+
BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
|
|
31
|
+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
32
|
+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
33
|
+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
|
|
34
|
+
FILES OR SOFTWARE.
|
|
35
|
+
|
|
36
|
+
Except as contained in this notice, the name of a copyright holder shall
|
|
37
|
+
not be used in advertising or otherwise to promote the sale, use or other
|
|
38
|
+
dealings in these Data Files or Software without prior written
|
|
39
|
+
authorization of the copyright holder.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@push.rocks/smartnftables",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A TypeScript module for managing nftables rules including NAT, firewall, and rate limiting with a high-level API.",
|
|
6
6
|
"main": "dist_ts/index.js",
|
|
@@ -9,16 +9,18 @@
|
|
|
9
9
|
"author": "Lossless GmbH",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@git.zone/cli": "
|
|
13
|
-
"@git.zone/tsbuild": "^4.4.
|
|
12
|
+
"@git.zone/cli": "6.13.2",
|
|
13
|
+
"@git.zone/tsbuild": "^4.4.3",
|
|
14
14
|
"@git.zone/tsrun": "^2.0.6",
|
|
15
|
-
"@git.zone/
|
|
16
|
-
"@
|
|
15
|
+
"@git.zone/tsrust": "1.13.0",
|
|
16
|
+
"@git.zone/tstest": "6.0.0",
|
|
17
|
+
"@types/node": "26.4.1",
|
|
17
18
|
"typescript": "^7.0.2"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
21
|
"@push.rocks/smartlog": "^3.2.2",
|
|
21
|
-
"@push.rocks/smartpromise": "^4.2.5"
|
|
22
|
+
"@push.rocks/smartpromise": "^4.2.5",
|
|
23
|
+
"@push.rocks/smartrust": "2.0.0"
|
|
22
24
|
},
|
|
23
25
|
"files": [
|
|
24
26
|
"ts/**/*",
|
|
@@ -27,8 +29,21 @@
|
|
|
27
29
|
"dist_ts/**/*",
|
|
28
30
|
"assets/**/*",
|
|
29
31
|
"readme.md",
|
|
30
|
-
"
|
|
32
|
+
"license.md",
|
|
33
|
+
"changelog.md",
|
|
34
|
+
"rust/Cargo.toml",
|
|
35
|
+
"rust/Cargo.lock",
|
|
36
|
+
"rust/.cargo/config.toml",
|
|
37
|
+
"rust/src/**/*",
|
|
38
|
+
"native-notices/**/*",
|
|
39
|
+
"scripts/check-native-notices.mjs"
|
|
31
40
|
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"executableFiles": [
|
|
43
|
+
"./dist_rust/smartnftables_linux_amd64_musl",
|
|
44
|
+
"./dist_rust/smartnftables_linux_arm64_musl"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
32
47
|
"keywords": [
|
|
33
48
|
"nftables",
|
|
34
49
|
"firewall",
|
|
@@ -51,7 +66,7 @@
|
|
|
51
66
|
},
|
|
52
67
|
"scripts": {
|
|
53
68
|
"test": "(tstest test/**/test*.ts --verbose --timeout 60)",
|
|
54
|
-
"build": "(tsbuild tsfolders)",
|
|
69
|
+
"build": "(node scripts/check-native-notices.mjs) && (tsbuild tsfolders) && (tsrust)",
|
|
55
70
|
"format": "(gitzone format)",
|
|
56
71
|
"buildDocs": "tsdoc"
|
|
57
72
|
}
|
package/readme.md
CHANGED
|
@@ -14,7 +14,165 @@ pnpm install @push.rocks/smartnftables
|
|
|
14
14
|
npm install @push.rocks/smartnftables
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
The legacy `SmartNftables` helper tracks rules without applying them when it lacks
|
|
18
|
+
root privileges. `ManagedNftables` always rejects unsupported enforcement; it has
|
|
19
|
+
no dry-run or memory-only enforcement mode.
|
|
20
|
+
|
|
21
|
+
## Managed workload policy
|
|
22
|
+
|
|
23
|
+
`ManagedNftables` provides a separate native owner for complete, interface-bound
|
|
24
|
+
IPv4 policy. It requires Linux **6.9 or newer**, `CAP_NET_ADMIN` in its network
|
|
25
|
+
namespace, and working nftables OWNER/PERSIST support. The published native matrix
|
|
26
|
+
is Linux x86_64 and arm64, statically linked with musl. Actual kernel support is
|
|
27
|
+
checked when applying policy; starting the compiler does not establish enforcement.
|
|
28
|
+
|
|
29
|
+
An optional caller-owned `networkNamespaceFd` selects an already-created Linux
|
|
30
|
+
network namespace. Keep that descriptor valid through `start()`. The native
|
|
31
|
+
process validates and enters its inherited copy before readiness, owner identity
|
|
32
|
+
capture or netlink activity, then closes the copy. Invalid descriptors and denied
|
|
33
|
+
entry fail before readiness. The option is process configuration and never enters
|
|
34
|
+
`openOwner`, policy commands or durable receipts. Native callers use
|
|
35
|
+
`--management --network-namespace-fd 3` with an inherited descriptor at FD 3.
|
|
36
|
+
|
|
37
|
+
The caller owns the namespace lifetime, links and routes. Retain a namespace
|
|
38
|
+
owner across process loss and recovery: PERSIST retains policy only while its
|
|
39
|
+
namespace exists. An entered process keeps its namespace membership if the source
|
|
40
|
+
descriptor is closed, but a replacement process requires a valid descriptor.
|
|
41
|
+
Receipts bind the actual target namespace device and inode; recovery in another
|
|
42
|
+
namespace rejects. Await complete policy and process cleanup before releasing
|
|
43
|
+
the caller's final namespace owner. Namespace entry does not create uplink
|
|
44
|
+
authority, drain conntrack flows or authorize address and port reuse.
|
|
45
|
+
|
|
46
|
+
The Linux x86_64 musl candidate passed nine isolated Linux 6.18.35 kernel tests,
|
|
47
|
+
including inherited namespace entry, retained policy after process loss, recovery
|
|
48
|
+
in the original namespace, rejection in another namespace, and denied entry
|
|
49
|
+
before readiness. ARM binaries are built; privileged ARM and complete Pallet
|
|
50
|
+
workload integration remain separate qualification requirements.
|
|
51
|
+
|
|
52
|
+
The caller owns workload links and durable state. Keep links disabled until their
|
|
53
|
+
policy is confirmed, serialize link changes with policy operations, and disable
|
|
54
|
+
them before cleanup. Persist the full prepared transition before calling
|
|
55
|
+
`reconcile()`, then retain the full returned receipt in the caller's SmartData
|
|
56
|
+
store. This library does not persist runtime state in files.
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { ManagedNftables } from '@push.rocks/smartnftables';
|
|
60
|
+
|
|
61
|
+
const owner = new ManagedNftables({
|
|
62
|
+
ownerId: 'node-policy',
|
|
63
|
+
instanceId: 'caller_retained_unique_instance',
|
|
64
|
+
tableName: 'snft_workloads',
|
|
65
|
+
});
|
|
66
|
+
await owner.start(); // Compiler/IPC readiness only; no kernel policy yet.
|
|
67
|
+
|
|
68
|
+
const target = await owner.prepare({
|
|
69
|
+
schemaVersion: 1,
|
|
70
|
+
revision: 1,
|
|
71
|
+
endpoints: [
|
|
72
|
+
{ id: 'workload-a', interfaceIndex: 12, interfaceName: 'worka', interfaceKind: 'veth', sourcePrefixes: ['10.81.1.2/32'] },
|
|
73
|
+
{ id: 'workload-b', interfaceIndex: 13, interfaceName: 'workb', interfaceKind: 'veth', sourcePrefixes: ['10.81.2.2/32'] },
|
|
74
|
+
],
|
|
75
|
+
rules: [
|
|
76
|
+
{
|
|
77
|
+
sourceEndpoint: 'workload-a', destinationEndpoint: 'workload-b',
|
|
78
|
+
sourcePrefix: '10.81.1.2/32', destinationPrefix: '10.81.2.2/32',
|
|
79
|
+
protocol: 'tcp', sourcePort: null, destinationPort: 443,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
sourceEndpoint: 'workload-b', destinationEndpoint: 'workload-a',
|
|
83
|
+
sourcePrefix: '10.81.2.2/32', destinationPrefix: '10.81.1.2/32',
|
|
84
|
+
protocol: 'tcp', sourcePort: 443, destinationPort: null,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
const transition = { previous: null, target };
|
|
89
|
+
// Persist this complete transition before the next operation.
|
|
90
|
+
const applied = await owner.reconcile(transition);
|
|
91
|
+
// Persist the complete applied result before enabling the caller-owned links.
|
|
92
|
+
const status = await owner.inspect();
|
|
93
|
+
if (!status.enforced) throw new Error('Workload policy is not confirmed.');
|
|
94
|
+
|
|
95
|
+
// After disabling/quiescing these workload links:
|
|
96
|
+
await owner.release(applied);
|
|
97
|
+
await owner.close();
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Interface numbers and names in this example must be replaced with the caller's
|
|
101
|
+
actual, already-created links. Native RTM_GETLINK checks the name/index pair,
|
|
102
|
+
the declared `veth` or L3 `tun` kind and absence of a bridge/master attachment.
|
|
103
|
+
The caller must prove and own each veth peer and workload network namespace.
|
|
104
|
+
Both selectors must match for a grant. A stale
|
|
105
|
+
name/index pair rejects application; renaming either selector retains denial.
|
|
106
|
+
Do not reuse interface identities or workload addresses while their previous
|
|
107
|
+
grants remain outstanding.
|
|
108
|
+
|
|
109
|
+
| Method | Behavior |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| `start()` | Starts one private native process and returns idle status. |
|
|
112
|
+
| `prepare(policy)` | Validates, canonicalizes and hashes an inert complete policy without kernel writes. |
|
|
113
|
+
| `reconcile({ previous, target })` | Creates or replaces the entire policy in one kernel transaction. `previous` is null initially, otherwise the full prior applied result. |
|
|
114
|
+
| `inspect()` | Reads the current owned graph and reports `enforced`, pending intent and a bounded error code. |
|
|
115
|
+
| `release(applied)` | Verifies the exact retained graph and confirms deletion; repeats are idempotent. |
|
|
116
|
+
| `close()` | Stops command admission, joins admitted policy operations, confirms owned-table deletion, then joins the native process. Failure retains the owner for explicit recovery. |
|
|
117
|
+
|
|
118
|
+
Policies are directed. Return traffic requires its own grant; there is no broad
|
|
119
|
+
connection-tracking bypass. A null endpoint denotes the actual local host, with an
|
|
120
|
+
explicit prefix that cannot overlap any endpoint. Such a grant applies only to
|
|
121
|
+
input/output. Forwarding requires two explicit endpoint references; a relay TUN
|
|
122
|
+
is an endpoint with `interfaceKind: 'tun'` and its authenticated remote source
|
|
123
|
+
prefixes. The relay owner must authenticate that remote source authority.
|
|
124
|
+
Managed interfaces reject other IPv4 traffic and IPv6 traffic. Ethernet/ARP
|
|
125
|
+
is outside these inet hooks; workload links must use the qualified routed layout.
|
|
126
|
+
Unmatched interfaces retain their existing behavior. The compiler creates
|
|
127
|
+
only inet input, forward and output filter chains; it does not configure links,
|
|
128
|
+
routes, NAT, DNS, host defaults, forwarding sysctls, or relay sessions. An ungranted
|
|
129
|
+
destination is denied independently of DNS answers.
|
|
130
|
+
|
|
131
|
+
The schema permits at most 32 interfaces, 16 source prefixes per interface and
|
|
132
|
+
128 directed rules, additionally bounded to 768 compiled operations and 100,000
|
|
133
|
+
encoded bytes. IPv4 prefixes must be canonical, non-overlapping local allocations;
|
|
134
|
+
loopback, unspecified and multicast allocations reject. Ports require explicit
|
|
135
|
+
TCP/UDP and all nullable fields must be present. The facade rejects getters,
|
|
136
|
+
proxies, live objects and concurrent commands rather than queuing unbounded work.
|
|
137
|
+
|
|
138
|
+
One NETLINK_NETFILTER socket exclusively owns the table with OWNER/PERSIST flags.
|
|
139
|
+
An acknowledged batch commits the complete graph atomically. Lost acknowledgements
|
|
140
|
+
retain the exact pending transition; retry only that same body. Reconnect/restart
|
|
141
|
+
uses the same caller-retained owner, instance, table and boot/namespace receipt.
|
|
142
|
+
Recovery checks the complete graph before and after orphan adoption. The kernel's
|
|
143
|
+
wrapping generation counter only fences concurrent transactions; it is never a
|
|
144
|
+
durable revision or sufficient ownership proof. Foreign owners, unexpected tables,
|
|
145
|
+
chains, rules, sets or objects reject without deletion.
|
|
146
|
+
|
|
147
|
+
PERSIST deliberately retains accepted static grants if the native process crashes.
|
|
148
|
+
It supplies no wall-clock lease or timed revocation. The caller must keep revocation
|
|
149
|
+
pending until policy replacement or workload fencing is confirmed. Host reboot
|
|
150
|
+
invalidates the old boot receipt; the caller must fence its old link/workload
|
|
151
|
+
lifecycle before starting a new owner instance. Cleanup failures and uncertain
|
|
152
|
+
operations must not be reported as successful release or used to transfer authority.
|
|
153
|
+
|
|
154
|
+
Apply and release receipts describe this owner's table and policy operations.
|
|
155
|
+
They do not certify that packets admitted under an earlier graph have drained:
|
|
156
|
+
foreign NFQUEUE or other deferred packet owners may still hold such packets.
|
|
157
|
+
The caller must qualify the complete packet path or independently fence the
|
|
158
|
+
workload before treating revocation as complete or reusing its addresses and
|
|
159
|
+
interfaces. Table deletion does not release IP allocation authority or clean up
|
|
160
|
+
conntrack/NAT state. This restriction also applies to private veth/TUN forwarding.
|
|
161
|
+
|
|
162
|
+
### Native qualification
|
|
163
|
+
|
|
164
|
+
`cargo test --manifest-path rust/Cargo.toml --locked` runs only unprivileged pure
|
|
165
|
+
tests. The ignored native cases require the explicitly marked disposable guest
|
|
166
|
+
from `test/native/qualify.py`; requesting them on an ordinary host fails its scope
|
|
167
|
+
check. Qualification uses an offline Linux 6.18.35 x86_64 guest with no host disks,
|
|
168
|
+
mounts or network devices, and guest-owned network namespaces/veth pairs. It covers
|
|
169
|
+
UDP/TCP grants, direct-IP denial, source spoofing, IPv6 denial, renamed interfaces,
|
|
170
|
+
foreign ownership, atomic rollback, generation conflicts and lost-ACK recovery.
|
|
171
|
+
The arm64 binary is cross-built; native packet qualification is currently x86_64.
|
|
172
|
+
Kernel 6.8 is unsupported. No production activation is implied by these tests.
|
|
173
|
+
|
|
174
|
+
Native dependency and standard-library attribution is included in
|
|
175
|
+
`native-notices/`. Distribution must retain these notices alongside the binaries.
|
|
18
176
|
|
|
19
177
|
## Quick Start
|
|
20
178
|
|
|
@@ -339,7 +497,7 @@ All interfaces and types are fully exported for use in your own code:
|
|
|
339
497
|
|
|
340
498
|
## License and Legal Information
|
|
341
499
|
|
|
342
|
-
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [repository license file](./license).
|
|
500
|
+
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [repository license file](./license.md).
|
|
343
501
|
|
|
344
502
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
|
345
503
|
|
package/rust/Cargo.lock
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "block-buffer"
|
|
7
|
+
version = "0.10.4"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"generic-array",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[package]]
|
|
15
|
+
name = "cfg-if"
|
|
16
|
+
version = "1.0.4"
|
|
17
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
18
|
+
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
19
|
+
|
|
20
|
+
[[package]]
|
|
21
|
+
name = "cpufeatures"
|
|
22
|
+
version = "0.2.17"
|
|
23
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
24
|
+
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
|
|
25
|
+
dependencies = [
|
|
26
|
+
"libc",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "crypto-common"
|
|
31
|
+
version = "0.1.7"
|
|
32
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
33
|
+
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
|
|
34
|
+
dependencies = [
|
|
35
|
+
"generic-array",
|
|
36
|
+
"typenum",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[[package]]
|
|
40
|
+
name = "digest"
|
|
41
|
+
version = "0.10.7"
|
|
42
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
43
|
+
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
|
44
|
+
dependencies = [
|
|
45
|
+
"block-buffer",
|
|
46
|
+
"crypto-common",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[[package]]
|
|
50
|
+
name = "generic-array"
|
|
51
|
+
version = "0.14.7"
|
|
52
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
53
|
+
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
|
54
|
+
dependencies = [
|
|
55
|
+
"typenum",
|
|
56
|
+
"version_check",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
[[package]]
|
|
60
|
+
name = "itoa"
|
|
61
|
+
version = "1.0.18"
|
|
62
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
63
|
+
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
|
64
|
+
|
|
65
|
+
[[package]]
|
|
66
|
+
name = "libc"
|
|
67
|
+
version = "0.2.189"
|
|
68
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
69
|
+
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
|
70
|
+
|
|
71
|
+
[[package]]
|
|
72
|
+
name = "memchr"
|
|
73
|
+
version = "2.8.3"
|
|
74
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
75
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
76
|
+
|
|
77
|
+
[[package]]
|
|
78
|
+
name = "proc-macro2"
|
|
79
|
+
version = "1.0.107"
|
|
80
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
81
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
82
|
+
dependencies = [
|
|
83
|
+
"unicode-ident",
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
[[package]]
|
|
87
|
+
name = "quote"
|
|
88
|
+
version = "1.0.47"
|
|
89
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
90
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
91
|
+
dependencies = [
|
|
92
|
+
"proc-macro2",
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
[[package]]
|
|
96
|
+
name = "serde"
|
|
97
|
+
version = "1.0.229"
|
|
98
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
99
|
+
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
|
100
|
+
dependencies = [
|
|
101
|
+
"serde_core",
|
|
102
|
+
"serde_derive",
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
[[package]]
|
|
106
|
+
name = "serde_core"
|
|
107
|
+
version = "1.0.229"
|
|
108
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
109
|
+
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
|
110
|
+
dependencies = [
|
|
111
|
+
"serde_derive",
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
[[package]]
|
|
115
|
+
name = "serde_derive"
|
|
116
|
+
version = "1.0.229"
|
|
117
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
118
|
+
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|
119
|
+
dependencies = [
|
|
120
|
+
"proc-macro2",
|
|
121
|
+
"quote",
|
|
122
|
+
"syn",
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
[[package]]
|
|
126
|
+
name = "serde_json"
|
|
127
|
+
version = "1.0.151"
|
|
128
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
129
|
+
checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
|
|
130
|
+
dependencies = [
|
|
131
|
+
"itoa",
|
|
132
|
+
"memchr",
|
|
133
|
+
"serde",
|
|
134
|
+
"serde_core",
|
|
135
|
+
"zmij",
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
[[package]]
|
|
139
|
+
name = "sha2"
|
|
140
|
+
version = "0.10.9"
|
|
141
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
142
|
+
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
|
|
143
|
+
dependencies = [
|
|
144
|
+
"cfg-if",
|
|
145
|
+
"cpufeatures",
|
|
146
|
+
"digest",
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
[[package]]
|
|
150
|
+
name = "smartnftables"
|
|
151
|
+
version = "0.1.0"
|
|
152
|
+
dependencies = [
|
|
153
|
+
"libc",
|
|
154
|
+
"serde",
|
|
155
|
+
"serde_json",
|
|
156
|
+
"sha2",
|
|
157
|
+
]
|
|
158
|
+
|
|
159
|
+
[[package]]
|
|
160
|
+
name = "syn"
|
|
161
|
+
version = "3.0.5"
|
|
162
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
163
|
+
checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9"
|
|
164
|
+
dependencies = [
|
|
165
|
+
"proc-macro2",
|
|
166
|
+
"quote",
|
|
167
|
+
"unicode-ident",
|
|
168
|
+
]
|
|
169
|
+
|
|
170
|
+
[[package]]
|
|
171
|
+
name = "typenum"
|
|
172
|
+
version = "1.20.1"
|
|
173
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
174
|
+
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
|
|
175
|
+
|
|
176
|
+
[[package]]
|
|
177
|
+
name = "unicode-ident"
|
|
178
|
+
version = "1.0.24"
|
|
179
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
180
|
+
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
181
|
+
|
|
182
|
+
[[package]]
|
|
183
|
+
name = "version_check"
|
|
184
|
+
version = "0.9.5"
|
|
185
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
186
|
+
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
|
187
|
+
|
|
188
|
+
[[package]]
|
|
189
|
+
name = "zmij"
|
|
190
|
+
version = "1.0.23"
|
|
191
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
192
|
+
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
package/rust/Cargo.toml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "smartnftables"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
publish = false
|
|
6
|
+
license = "MIT"
|
|
7
|
+
description = "Owned, atomic Linux nftables managed policy engine"
|
|
8
|
+
|
|
9
|
+
[dependencies]
|
|
10
|
+
libc = "=0.2.189"
|
|
11
|
+
serde = { version = "=1.0.229", features = ["derive"] }
|
|
12
|
+
serde_json = { version = "=1.0.151", features = ["raw_value"] }
|
|
13
|
+
sha2 = "=0.10.9"
|