├── .codespellrc ├── .env ├── .gitattributes ├── .github ├── FUNDING.yml └── workflows │ ├── dco.yml │ └── rust.yml ├── .gitignore ├── .justfile ├── .reuse └── dep5 ├── .rustfmt.toml ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── LICENSES ├── Apache-2.0.txt ├── CC0-1.0.txt └── MIT.txt ├── README.md ├── SECURITY.md ├── allowed_signers ├── deny.toml ├── fixtures ├── README.md ├── README.sh ├── ssh-openpgp-auth.md └── ssh-openpgp-auth.sh ├── scripts └── hooks │ ├── pre-commit │ └── pre-push ├── src ├── lib.rs └── main.rs └── tests └── all.rs /.codespellrc: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Wiktor Kwapisiewicz 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | [codespell] 5 | skip = .cargo,.git,target,.env,Cargo.lock 6 | ignore-words-list = crate 7 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2024 Wiktor Kwapisiewicz 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | # Contains project specific files 5 | 6 | # List of packages required specifically by this project 7 | PACMAN_PACKAGES="clang" 8 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: wiktor-k 2 | -------------------------------------------------------------------------------- /.github/workflows/dco.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Wiktor Kwapisiewicz 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | name: DCO 5 | 6 | on: [pull_request] 7 | 8 | jobs: 9 | check-dco: 10 | name: Check commits for sign-offs 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: KineticCafe/actions-dco@v1 14 | -------------------------------------------------------------------------------- /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | pull_request: 5 | push: 6 | tags: 7 | - 'v*' 8 | branches: [ main ] 9 | workflow_dispatch: 10 | 11 | concurrency: 12 | group: rust-${{ github.ref }} 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | check-spelling: 17 | name: Check spelling 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v4 21 | - run: cargo install --locked just 22 | - run: sudo apt-get install -y codespell 23 | - name: Check spelling 24 | run: just spelling 25 | 26 | formatting: 27 | name: Check formatting 28 | strategy: 29 | matrix: 30 | include: 31 | - os: ubuntu-latest 32 | - os: macos-latest 33 | - os: windows-latest 34 | runs-on: ${{ matrix.os }} 35 | steps: 36 | - uses: actions/checkout@v4 37 | - run: cargo install --locked just 38 | - run: rustup install nightly 39 | - run: rustup component add rustfmt --toolchain nightly 40 | - name: Check formatting 41 | run: just formatting 42 | 43 | tests: 44 | name: Unit tests 45 | strategy: 46 | matrix: 47 | include: 48 | - os: ubuntu-latest 49 | - os: macos-latest 50 | - os: windows-latest 51 | runs-on: ${{ matrix.os }} 52 | steps: 53 | - uses: actions/checkout@v4 54 | - run: cargo install --locked just 55 | - name: Run unit tests 56 | run: just tests 57 | 58 | deps: 59 | name: Check dependencies 60 | strategy: 61 | matrix: 62 | include: 63 | - os: ubuntu-latest 64 | - os: macos-latest 65 | - os: windows-latest 66 | runs-on: ${{ matrix.os }} 67 | steps: 68 | - uses: actions/checkout@v4 69 | - run: cargo install --locked just cargo-deny 70 | - name: Run dependencies check 71 | run: just dependencies 72 | 73 | lints: 74 | name: Clippy lints 75 | strategy: 76 | matrix: 77 | include: 78 | - os: ubuntu-latest 79 | - os: macos-latest 80 | - os: windows-latest 81 | runs-on: ${{ matrix.os }} 82 | steps: 83 | - uses: actions/checkout@v4 84 | - run: cargo install --locked just 85 | - name: Check for lints 86 | run: just lints 87 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Wiktor Kwapisiewicz 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | /target 5 | -------------------------------------------------------------------------------- /.justfile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S just --working-directory . --justfile 2 | # Since this is a first recipe it's being run by default. 3 | # Faster checks need to be executed first for better UX. For example 4 | 5 | # codespell is very fast. cargo fmt does not need to download crates etc. 6 | check: spelling formatting docs lints dependencies tests 7 | 8 | # Checks common spelling mistakes 9 | spelling: 10 | codespell 11 | 12 | # Checks source code formatting 13 | formatting: 14 | just --unstable --fmt --check 15 | # We're using nightly to properly group imports, see .rustfmt.toml 16 | cargo +nightly fmt --all -- --check 17 | 18 | # Lints the source code 19 | lints: 20 | cargo clippy --workspace --no-deps --all-targets -- -D warnings 21 | 22 | # Checks for issues with dependencies 23 | dependencies: 24 | cargo deny check 25 | 26 | # Runs all unit tests. By default ignored tests are not run. Run with `ignored=true` to run only ignored tests 27 | tests: 28 | cargo test --all 29 | 30 | # Build docs for this crate only 31 | docs: 32 | cargo doc --no-deps 33 | 34 | # Checks for commit messages 35 | check-commits REFS='main..': 36 | #!/usr/bin/env bash 37 | set -euo pipefail 38 | for commit in $(git rev-list "{{ REFS }}"); do 39 | MSG="$(git show -s --format=%B "$commit")" 40 | CODESPELL_RC="$(mktemp)" 41 | git show "$commit:.codespellrc" > "$CODESPELL_RC" 42 | if ! grep -q "Signed-off-by: " <<< "$MSG"; then 43 | printf "Commit %s lacks \"Signed-off-by\" line.\n" "$commit" 44 | printf "%s\n" \ 45 | " Please use:" \ 46 | " git rebase --signoff main && git push --force-with-lease" \ 47 | " See https://developercertificate.org/ for more details." 48 | exit 1; 49 | elif ! codespell --config "$CODESPELL_RC" - <<< "$MSG"; then 50 | printf "The spelling in commit %s needs improvement.\n" "$commit" 51 | exit 1; 52 | else 53 | printf "Commit %s is good.\n" "$commit" 54 | fi 55 | done 56 | 57 | # Fixes common issues. Files need to be git add'ed 58 | fix: 59 | #!/usr/bin/env bash 60 | if ! git diff-files --quiet ; then 61 | echo "Working tree has changes. Please stage them: git add ." 62 | exit 1 63 | fi 64 | 65 | codespell --write-changes 66 | just --unstable --fmt 67 | cargo clippy --fix --allow-staged 68 | 69 | # fmt must be last as clippy's changes may break formatting 70 | cargo +nightly fmt --all 71 | -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: tangler 3 | Upstream-Contact: Wiktor Kwapisiewicz 4 | Source: https://github.com/wiktor-k/tangler 5 | 6 | Files: Cargo.lock fixtures/README.sh fixtures/ssh-openpgp-auth.sh 7 | Copyright: 2023 Wiktor Kwapisiewicz 8 | License: CC0-1.0 9 | 10 | # Sample paragraph, commented out: 11 | # 12 | # Files: src/* 13 | # Copyright: $YEAR $NAME <$CONTACT> 14 | # License: ... 15 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | group_imports = "StdExternalCrate" 2 | format_code_in_doc_comments = true 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Thanks for taking the time to contribute to this project! 4 | 5 | All changes need to: 6 | 7 | - pass basic checks, including tests, formatting and lints, 8 | - be signed-off. 9 | 10 | ## Basic checks 11 | 12 | We are using standard Rust ecosystem tools including `rustfmt` and `clippy` with one minor difference. 13 | Due to a couple of `rustfmt` features being available only in nightly (see the `.rustfmt.toml` file) nightly `rustfmt` is necessary. 14 | 15 | All of these details are captured in a `.justfile` and can be checked by running [`just`'](https://just.systems/). 16 | 17 | To run all checks locally before sending them to CI you can set your git hooks directory: 18 | 19 | ```sh 20 | git config core.hooksPath scripts/hooks/ 21 | ``` 22 | 23 | ## Developer Certificate of Origin 24 | 25 | The sign-off is a simple line at the end of the git commit message, which certifies that you wrote it or otherwise have the right to pass it on as a open-source patch. 26 | 27 | The rules are pretty simple: if you can [certify the below][DCO]: 28 | 29 | ``` 30 | Developer's Certificate of Origin 1.1 31 | 32 | By making a contribution to this project, I certify that: 33 | 34 | (a) The contribution was created in whole or in part by me and I 35 | have the right to submit it under the open source license 36 | indicated in the file; or 37 | 38 | (b) The contribution is based upon previous work that, to the best 39 | of my knowledge, is covered under an appropriate open source 40 | license and I have the right under that license to submit that 41 | work with modifications, whether created in whole or in part 42 | by me, under the same open source license (unless I am 43 | permitted to submit under a different license), as indicated 44 | in the file; or 45 | 46 | (c) The contribution was provided directly to me by some other 47 | person who certified (a), (b) or (c) and I have not modified 48 | it. 49 | 50 | (d) I understand and agree that this project and the contribution 51 | are public and that a record of the contribution (including all 52 | personal information I submit with it, including my sign-off) is 53 | maintained indefinitely and may be redistributed consistent with 54 | this project or the open source license(s) involved. 55 | ``` 56 | 57 | then you just add a line saying 58 | 59 | Signed-off-by: Random J Developer 60 | 61 | using your name. 62 | 63 | If you set your `user.name` and `user.email`, you can sign your commit automatically with [`git commit --signoff`][GSO]. 64 | 65 | To sign-off your last commit: 66 | 67 | git commit --amend --signoff 68 | 69 | [DCO]: https://developercertificate.org 70 | [GSO]: https://git-scm.com/docs/git-commit#git-commit---signoff 71 | 72 | If you want to fix multiple commits use: 73 | 74 | git rebase --signoff main 75 | 76 | To check if your commits are correctly signed-off locally use `just check-commits`. 77 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "aho-corasick" 7 | version = "1.1.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" 10 | dependencies = [ 11 | "memchr", 12 | ] 13 | 14 | [[package]] 15 | name = "autocfg" 16 | version = "1.1.0" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 19 | 20 | [[package]] 21 | name = "cfg-if" 22 | version = "1.0.0" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 25 | 26 | [[package]] 27 | name = "futures" 28 | version = "0.3.30" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" 31 | dependencies = [ 32 | "futures-channel", 33 | "futures-core", 34 | "futures-executor", 35 | "futures-io", 36 | "futures-sink", 37 | "futures-task", 38 | "futures-util", 39 | ] 40 | 41 | [[package]] 42 | name = "futures-channel" 43 | version = "0.3.30" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" 46 | dependencies = [ 47 | "futures-core", 48 | "futures-sink", 49 | ] 50 | 51 | [[package]] 52 | name = "futures-core" 53 | version = "0.3.30" 54 | source = "registry+https://github.com/rust-lang/crates.io-index" 55 | checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" 56 | 57 | [[package]] 58 | name = "futures-executor" 59 | version = "0.3.30" 60 | source = "registry+https://github.com/rust-lang/crates.io-index" 61 | checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" 62 | dependencies = [ 63 | "futures-core", 64 | "futures-task", 65 | "futures-util", 66 | ] 67 | 68 | [[package]] 69 | name = "futures-io" 70 | version = "0.3.30" 71 | source = "registry+https://github.com/rust-lang/crates.io-index" 72 | checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" 73 | 74 | [[package]] 75 | name = "futures-macro" 76 | version = "0.3.30" 77 | source = "registry+https://github.com/rust-lang/crates.io-index" 78 | checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" 79 | dependencies = [ 80 | "proc-macro2", 81 | "quote", 82 | "syn", 83 | ] 84 | 85 | [[package]] 86 | name = "futures-sink" 87 | version = "0.3.30" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" 90 | 91 | [[package]] 92 | name = "futures-task" 93 | version = "0.3.30" 94 | source = "registry+https://github.com/rust-lang/crates.io-index" 95 | checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" 96 | 97 | [[package]] 98 | name = "futures-timer" 99 | version = "3.0.2" 100 | source = "registry+https://github.com/rust-lang/crates.io-index" 101 | checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" 102 | 103 | [[package]] 104 | name = "futures-util" 105 | version = "0.3.30" 106 | source = "registry+https://github.com/rust-lang/crates.io-index" 107 | checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" 108 | dependencies = [ 109 | "futures-channel", 110 | "futures-core", 111 | "futures-io", 112 | "futures-macro", 113 | "futures-sink", 114 | "futures-task", 115 | "memchr", 116 | "pin-project-lite", 117 | "pin-utils", 118 | "slab", 119 | ] 120 | 121 | [[package]] 122 | name = "glob" 123 | version = "0.3.1" 124 | source = "registry+https://github.com/rust-lang/crates.io-index" 125 | checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" 126 | 127 | [[package]] 128 | name = "memchr" 129 | version = "2.7.1" 130 | source = "registry+https://github.com/rust-lang/crates.io-index" 131 | checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" 132 | 133 | [[package]] 134 | name = "pin-project-lite" 135 | version = "0.2.13" 136 | source = "registry+https://github.com/rust-lang/crates.io-index" 137 | checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" 138 | 139 | [[package]] 140 | name = "pin-utils" 141 | version = "0.1.0" 142 | source = "registry+https://github.com/rust-lang/crates.io-index" 143 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 144 | 145 | [[package]] 146 | name = "proc-macro2" 147 | version = "1.0.76" 148 | source = "registry+https://github.com/rust-lang/crates.io-index" 149 | checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" 150 | dependencies = [ 151 | "unicode-ident", 152 | ] 153 | 154 | [[package]] 155 | name = "quote" 156 | version = "1.0.35" 157 | source = "registry+https://github.com/rust-lang/crates.io-index" 158 | checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" 159 | dependencies = [ 160 | "proc-macro2", 161 | ] 162 | 163 | [[package]] 164 | name = "regex" 165 | version = "1.10.2" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" 168 | dependencies = [ 169 | "aho-corasick", 170 | "memchr", 171 | "regex-automata", 172 | "regex-syntax", 173 | ] 174 | 175 | [[package]] 176 | name = "regex-automata" 177 | version = "0.4.3" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" 180 | dependencies = [ 181 | "aho-corasick", 182 | "memchr", 183 | "regex-syntax", 184 | ] 185 | 186 | [[package]] 187 | name = "regex-syntax" 188 | version = "0.8.2" 189 | source = "registry+https://github.com/rust-lang/crates.io-index" 190 | checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" 191 | 192 | [[package]] 193 | name = "relative-path" 194 | version = "1.9.2" 195 | source = "registry+https://github.com/rust-lang/crates.io-index" 196 | checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" 197 | 198 | [[package]] 199 | name = "rstest" 200 | version = "0.18.2" 201 | source = "registry+https://github.com/rust-lang/crates.io-index" 202 | checksum = "97eeab2f3c0a199bc4be135c36c924b6590b88c377d416494288c14f2db30199" 203 | dependencies = [ 204 | "futures", 205 | "futures-timer", 206 | "rstest_macros", 207 | "rustc_version", 208 | ] 209 | 210 | [[package]] 211 | name = "rstest_macros" 212 | version = "0.18.2" 213 | source = "registry+https://github.com/rust-lang/crates.io-index" 214 | checksum = "d428f8247852f894ee1be110b375111b586d4fa431f6c46e64ba5a0dcccbe605" 215 | dependencies = [ 216 | "cfg-if", 217 | "glob", 218 | "proc-macro2", 219 | "quote", 220 | "regex", 221 | "relative-path", 222 | "rustc_version", 223 | "syn", 224 | "unicode-ident", 225 | ] 226 | 227 | [[package]] 228 | name = "rustc_version" 229 | version = "0.4.0" 230 | source = "registry+https://github.com/rust-lang/crates.io-index" 231 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 232 | dependencies = [ 233 | "semver", 234 | ] 235 | 236 | [[package]] 237 | name = "semver" 238 | version = "1.0.21" 239 | source = "registry+https://github.com/rust-lang/crates.io-index" 240 | checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" 241 | 242 | [[package]] 243 | name = "slab" 244 | version = "0.4.9" 245 | source = "registry+https://github.com/rust-lang/crates.io-index" 246 | checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" 247 | dependencies = [ 248 | "autocfg", 249 | ] 250 | 251 | [[package]] 252 | name = "syn" 253 | version = "2.0.48" 254 | source = "registry+https://github.com/rust-lang/crates.io-index" 255 | checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" 256 | dependencies = [ 257 | "proc-macro2", 258 | "quote", 259 | "unicode-ident", 260 | ] 261 | 262 | [[package]] 263 | name = "tangler" 264 | version = "0.3.0" 265 | dependencies = [ 266 | "rstest", 267 | "testresult", 268 | ] 269 | 270 | [[package]] 271 | name = "testresult" 272 | version = "0.3.0" 273 | source = "registry+https://github.com/rust-lang/crates.io-index" 274 | checksum = "52e045f5cf9ad69772c1c9652f5567a75df88bbb5a1310a64e53cab140c5c459" 275 | 276 | [[package]] 277 | name = "unicode-ident" 278 | version = "1.0.6" 279 | source = "registry+https://github.com/rust-lang/crates.io-index" 280 | checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" 281 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Wiktor Kwapisiewicz 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | [package] 5 | name = "tangler" 6 | version = "0.3.0" 7 | edition = "2021" 8 | authors = ["Wiktor Kwapisiewicz "] 9 | description = "Extracts code blocks from Markdown documents" 10 | license = "MIT OR Apache-2.0" 11 | repository = "https://github.com/wiktor-k/tangler" 12 | 13 | [dev-dependencies] 14 | rstest = "0.18.2" 15 | testresult = "0.3.0" 16 | 17 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2023 Wiktor Kwapisiewicz 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /LICENSES/Apache-2.0.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 10 | 11 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 12 | 13 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 14 | 15 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 16 | 17 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 18 | 19 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. 20 | 21 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). 22 | 23 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. 24 | 25 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." 26 | 27 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 28 | 29 | 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 30 | 31 | 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 32 | 33 | 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 34 | 35 | (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and 36 | 37 | (b) You must cause any modified files to carry prominent notices stating that You changed the files; and 38 | 39 | (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 40 | 41 | (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. 42 | 43 | You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 44 | 45 | 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 46 | 47 | 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 48 | 49 | 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 50 | 51 | 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 52 | 53 | 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. 54 | 55 | END OF TERMS AND CONDITIONS 56 | 57 | APPENDIX: How to apply the Apache License to your work. 58 | 59 | To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. 60 | 61 | Copyright [yyyy] [name of copyright owner] 62 | 63 | Licensed under the Apache License, Version 2.0 (the "License"); 64 | you may not use this file except in compliance with the License. 65 | You may obtain a copy of the License at 66 | 67 | http://www.apache.org/licenses/LICENSE-2.0 68 | 69 | Unless required by applicable law or agreed to in writing, software 70 | distributed under the License is distributed on an "AS IS" BASIS, 71 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 72 | See the License for the specific language governing permissions and 73 | limitations under the License. 74 | -------------------------------------------------------------------------------- /LICENSES/CC0-1.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # Tangler 7 | 8 | [![CI](https://github.com/wiktor-k/tangler/actions/workflows/rust.yml/badge.svg)](https://github.com/wiktor-k/tangler/actions/workflows/rust.yml) 9 | [![Crates.io](https://img.shields.io/crates/v/tangler)](https://crates.io/crates/tangler) 10 | 11 | Extracts (tangles) code fragments from Markdown documents. 12 | 13 | This can be used to test examples in README documents to make sure they are always up to date. 14 | 15 | The most common use of this crate is installing it as part of the CI script, extracting selected code fragments and then executing them. 16 | 17 | ```bash 18 | cargo install tangler 19 | tangler bash < README.md | bash -euxo pipefail - 20 | ``` 21 | 22 | The first argument is a selector of the blocks that should be extracted. The tool takes the input markdown document from stdin and outputs only matching blocks to stdout. 23 | 24 | ## License 25 | 26 | This project is licensed under either of: 27 | 28 | - [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0), 29 | - [MIT license](https://opensource.org/licenses/MIT). 30 | 31 | at your option. 32 | 33 | ### Contribution 34 | 35 | Unless you explicitly state otherwise, any contribution intentionally 36 | submitted for inclusion in this crate by you, as defined in the 37 | Apache-2.0 license, shall be dual licensed as above, without any 38 | additional terms or conditions. 39 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security policy 2 | 3 | If you have discovered a security vulnerability in this project, please report it privately. 4 | Do not disclose it as a public issue. 5 | This gives us time to work with you to fix the issue before public exposure, reducing the chance that the exploit will be used before a patch is released. 6 | 7 | This project is maintained by a team of volunteers on a reasonable-effort basis. 8 | As such, please give us at least 90 days to work on a fix before public exposure. 9 | We will contact you back within 2 business days after reporting the issue. 10 | 11 | Thanks for helping make the project safe for everyone! 12 | 13 | ## Reporting a vulnerability 14 | 15 | Please, report the vulnerability either through [new security advisory form][ADV] or by directly contacting our security contacts. 16 | 17 | [ADV]: https://github.com/wiktor-k/tangler/security/advisories/new 18 | 19 | Security contacts: 20 | - [Wiktor Kwapisiewicz][WK], preferably encrypted with the following OpenPGP certificate: [`6539 09A2 F0E3 7C10 6F5F AF54 6C88 57E0 D8E8 F074`][KEY]. 21 | 22 | [WK]: https://github.com/wiktor-k 23 | [KEY]: https://keys.openpgp.org/vks/v1/by-fingerprint/653909A2F0E37C106F5FAF546C8857E0D8E8F074 24 | 25 | ## Supported Versions 26 | 27 | Security updates are applied only to the most recent release. 28 | -------------------------------------------------------------------------------- /allowed_signers: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Wiktor Kwapisiewicz 2 | # SPDX-License-Identifier: CC0-1.0 3 | 4 | wiktor@metacode.biz ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQv2RJtGurpNLWyiGz9sSuX8agzV98gHW2ZG/7vFkIQrPlaYsd/OH1z7BZNeCHs5vcoq6c2Eh5s6a0vcH4n181TKfjgpbq4t7OFNygWBJplXIZvIlsY//UCxfp5ZdKWJfrYUu/0HeEv5r/7ZcpwF/omC97aM0ipmAeQ8QEGLfgGW427ATa/r2SFwK/4h0C+BTUnMj/YC/4KI/MPWA6x7RdAw+RbVjZd4kT2ZPXcUdruSqDQ4vSP/b8gERv1IjWUn+HHteRJgR2SwNmsuuT/Ko3FRFfXxXPV2yMEvUY2+DoU781VhZJl0aqpW5bIhlK5VE5rGvmMuE5S7XwYDM9V0Wl 5 | wiktor@metacode.biz ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBO3Pw0e4zv7ZkciWKUCSHkRQJw70nIDPkvLGD0MzJ4uXJMp2kSgANNJDfhpabQrIAeNkXAivxWIrl0mrO58e/lUuUE1Z6YaM7duoI4CfKVE0rZLP45tNyFH9LQzcvz03kA== 6 | wiktor@metacode.biz ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBButvOpt5qRRPazVFSfV6a4A33eXtlVkXL7x4PHr2zryw1wGb7tzpuSTZKabJaTlSZP/Jpva2caGNNtoNbXVDisOsiS4/wSa3AJ2/PmxOcpv/lZcpCynKq4zDeogo+FxrA== 7 | -------------------------------------------------------------------------------- /deny.toml: -------------------------------------------------------------------------------- 1 | [advisories] 2 | version = 2 3 | yanked = "deny" 4 | ignore = [ 5 | ] 6 | 7 | [bans] 8 | deny = [ 9 | ] 10 | multiple-versions = "allow" 11 | 12 | [licenses] 13 | version = 2 14 | allow = [ 15 | "Apache-2.0", 16 | "MIT", 17 | ] 18 | -------------------------------------------------------------------------------- /fixtures/README.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # Test fixtures 7 | 8 | This directory contains files that are used for testing `tangler`. 9 | 10 | Each code snippet is extracted and compared with a known-good output: 11 | 12 | ```sh 13 | OUTPUT=$(echo test) 14 | 15 | [ "$OUTPUT" = "test" ] 16 | ``` 17 | -------------------------------------------------------------------------------- /fixtures/README.sh: -------------------------------------------------------------------------------- 1 | OUTPUT=$(echo test) 2 | 3 | [ "$OUTPUT" = "test" ] 4 | 5 | -------------------------------------------------------------------------------- /fixtures/ssh-openpgp-auth.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # `ssh-openpgp-auth` 7 | 8 | This tool provides client-side functionality to transparently verify the identity of remote SSH hosts, based on trust chains rooted in the user's OpenPGP configuration. 9 | 10 | Concretely, this tool fetches OpenPGP certificates for remote SSH hosts before opening SSH connections. The host certificate is verified based on OpenPGP trust chains, starting from the user's configured trust roots. If there is a valid trust chain, this tool adds the remote host's SSH public key to the local OpenSSH "known host" configuration. 11 | 12 | To gracefully handle host key life cycle events, the remote host's OpenPGP certificate is automatically refreshed when it expires. 13 | 14 | All OpenPGP certificates are stored locally in the standard [CertD](https://datatracker.ietf.org/doc/draft-nwjw-openpgp-cert-d/) directory (e.g. on Linux the default path is `.local/share/pgp.cert.d`, see [3.8. Platform-specific conventions](https://www.ietf.org/archive/id/draft-nwjw-openpgp-cert-d-00.html#section-3.8)). 15 | 16 | ## Installation 17 | 18 | This tool can be used either on a per-remote-host basis, or globally, by editing the `.ssh/config` file: 19 | 20 | ``` 21 | Host example.com 22 | KnownHostsCommand /usr/bin/ssh-openpgp-auth authenticate %H 23 | ``` 24 | 25 | ## Verification flags 26 | 27 | By default, this tool fetches missing certificates and does basic integrity checks on the remote host's certificate. It is possible to enable stricter checks by appending additional flags. Additional verification flags cause the tool to perform stricter checks. 28 | 29 | ### Web of Trust verification (`--verify-wot`) 30 | 31 | The following example illustrates defining trust roots in the user's OpenPGP certificate store, to perform host certificate verification using the Web of Trust. 32 | 33 | Note that if the user already has a Web of Trust setup (e.g., to rely on their organization's OpenPGP CA instance), these trust roots are leveraged automatically. This tool will then "just work", and rely on chains from trust roots to remote host certificates. Remote host certificates are automatically fetched over the network (using the WKD protocol), and trust calculations happen locally whenever the tool runs. 34 | 35 | ### DNS/Keyoxide proof verification (`--verify-dns-proof`) 36 | 37 | This validation requires that the key fingerprint is present in the DNS zone of a host: 38 | 39 | ``` 40 | $ dig +short TXT metacode.biz 41 | "openpgp4fpr:198c722a4bac336e9daaae44579d01b3abe1540e" 42 | "openpgp4fpr:653909a2f0e37c106f5faf546c8857e0d8e8f074" 43 | ``` 44 | 45 | The exact format will be specified in the future (see [issue #25](https://codeberg.org/wiktor/ssh-openpgp-auth/issues/25)). 46 | 47 | ## Usage example 48 | 49 | Let's do an example run of using this tool in an isolated environment. To set up a test environment, we configure a temporary directory to use as OpenPGP certificate store: 50 | 51 | ```sh 52 | export SQ_CERT_STORE=$(mktemp -d) 53 | export PGP_CERT_D=$SQ_CERT_STORE 54 | ``` 55 | 56 | Then we import the sample host certificate (which has the fingerprint `D9E95D7F42E87610676C40B47E8432836DA1625E`) into our temporary local certificate store, and directly configure it as a local trust root: 57 | 58 | ```sh 59 | sq import < fixtures/example.asc 60 | 61 | sq link add --all D9E95D7F42E87610676C40B47E8432836DA1625E 62 | ``` 63 | 64 | After defining the certificate as a trust root, the "known hosts" configuration contains a single authentication key in SSH format: 65 | 66 | ```sh 67 | KNOWN_HOSTS=$(ssh-openpgp-auth authenticate --verify-wot example.com) 68 | 69 | [ "$KNOWN_HOSTS" = "example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIUDdSi3z0/ePRqteV3Gk5MRZ7ZKenxcqDatCZDzimpLSTA== D9E95D7F42E87610676C40B47E8432836DA1625E/F5CEDEED08E9EA536034F5823475162385DF08AF" ] 70 | ``` 71 | 72 | Next, we retract the link again, which means that we don't rely on this certificate as a trust root anymore. 73 | 74 | Note that because the resolution of timestamps on OpenPGP signatures is limited to full seconds, we wait for two seconds to make sure the changed trust root configuration is in effect: 75 | 76 | ```sh 77 | sleep 2 78 | sq --force link retract D9E95D7F42E87610676C40B47E8432836DA1625E '' 79 | sleep 2 80 | ``` 81 | 82 | After unsetting this trust root, the SSH "known hosts" configuration is empty again, because the Web of Trust verification does not yield any valid SSH host certificates: 83 | 84 | ```sh 85 | KNOWN_HOSTS=$(ssh-openpgp-auth authenticate --verify-wot example.com) 86 | 87 | [ "$KNOWN_HOSTS" = "" ] 88 | ``` 89 | -------------------------------------------------------------------------------- /fixtures/ssh-openpgp-auth.sh: -------------------------------------------------------------------------------- 1 | export SQ_CERT_STORE=$(mktemp -d) 2 | export PGP_CERT_D=$SQ_CERT_STORE 3 | 4 | sq import < fixtures/example.asc 5 | 6 | sq link add --all D9E95D7F42E87610676C40B47E8432836DA1625E 7 | 8 | KNOWN_HOSTS=$(ssh-openpgp-auth authenticate --verify-wot example.com) 9 | 10 | [ "$KNOWN_HOSTS" = "example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIUDdSi3z0/ePRqteV3Gk5MRZ7ZKenxcqDatCZDzimpLSTA== D9E95D7F42E87610676C40B47E8432836DA1625E/F5CEDEED08E9EA536034F5823475162385DF08AF" ] 11 | 12 | sleep 2 13 | sq --force link retract D9E95D7F42E87610676C40B47E8432836DA1625E '' 14 | sleep 2 15 | 16 | KNOWN_HOSTS=$(ssh-openpgp-auth authenticate --verify-wot example.com) 17 | 18 | [ "$KNOWN_HOSTS" = "" ] 19 | 20 | -------------------------------------------------------------------------------- /scripts/hooks/pre-commit: -------------------------------------------------------------------------------- 1 | ../../.justfile -------------------------------------------------------------------------------- /scripts/hooks/pre-push: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -euo pipefail 4 | 5 | just check-commits 6 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Wiktor Kwapisiewicz 2 | // SPDX-License-Identifier: Apache-2.0 OR MIT 3 | 4 | #![doc = include_str!("../README.md")] 5 | #![deny(missing_debug_implementations)] 6 | #![deny(missing_docs)] 7 | 8 | use std::io::{BufRead, BufReader, Read, Result, Write}; 9 | 10 | /// Extracts expected code-blocks from Markdown source and writes them into sink. 11 | /// 12 | /// Multiple expected code-block infos can be passed. In this case it's 13 | /// sufficient for any one of them to match for the code-block to be printed. 14 | /// 15 | /// This function will not lint the source and assumes that the input is a valid 16 | /// Markdown document. 17 | /// 18 | /// # Examples 19 | /// 20 | /// ``` 21 | /// use std::io::Write; 22 | /// 23 | /// # fn main() -> testresult::TestResult { 24 | /// let source = r#"```sh 25 | /// echo x 26 | /// ```"#; 27 | /// let mut sink = Vec::new(); 28 | /// 29 | /// tangler::extract(source.as_bytes(), &mut sink, &["sh"])?; 30 | /// 31 | /// assert_eq!(&b"echo x\n\n"[..], &sink[..]); 32 | /// # Ok(()) } 33 | /// ``` 34 | pub fn extract( 35 | source: impl Read, 36 | mut sink: impl Write, 37 | expected: &[impl AsRef], 38 | ) -> Result<()> { 39 | let mut outputting = false; 40 | for line in BufReader::new(source).lines() { 41 | let line = line?; 42 | if line == "```" && outputting { 43 | sink.write_all(b"\n")?; 44 | outputting = false; 45 | } else if line.starts_with("```") && expected.iter().any(|info| info.as_ref() == &line[3..]) 46 | { 47 | outputting = true; 48 | } else if outputting { 49 | sink.write_all(line.as_bytes())?; 50 | sink.write_all(b"\n")?; 51 | } 52 | } 53 | 54 | Ok(()) 55 | } 56 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Wiktor Kwapisiewicz 2 | // SPDX-License-Identifier: Apache-2.0 OR MIT 3 | 4 | use tangler::extract; 5 | 6 | fn main() -> std::io::Result<()> { 7 | extract( 8 | std::io::stdin(), 9 | std::io::stdout(), 10 | &std::env::args().skip(1).collect::>(), 11 | )?; 12 | Ok(()) 13 | } 14 | -------------------------------------------------------------------------------- /tests/all.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Wiktor Kwapisiewicz 2 | // SPDX-License-Identifier: Apache-2.0 OR MIT 3 | 4 | use std::fs::read_to_string; 5 | use std::path::PathBuf; 6 | 7 | use rstest::rstest; 8 | use tangler::extract; 9 | use testresult::TestResult; 10 | 11 | #[rstest] 12 | fn main( 13 | #[files("fixtures/*")] 14 | #[exclude("md")] 15 | mut path: PathBuf, 16 | ) -> TestResult { 17 | let extension = path.extension().expect("test file to have an extension"); 18 | let extension: String = extension.to_string_lossy().into(); 19 | let output = read_to_string(&path)?; 20 | // construct input file name 21 | path.set_extension("md"); 22 | let input = read_to_string(&path)?; 23 | let mut actual_output = vec![]; 24 | extract(input.as_bytes(), &mut actual_output, &[extension])?; 25 | assert_eq!( 26 | output, 27 | String::from_utf8(actual_output)?, 28 | "Actual output should be the same as expected output" 29 | ); 30 | 31 | Ok(()) 32 | } 33 | --------------------------------------------------------------------------------