Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bf5becdc32 | |||
| 44452e3815 | |||
| 987d49c116 | |||
| b942c24077 | |||
| a3b3a32745 | |||
| 0eee7632ae | |||
| 6588461438 | |||
| e533a38883 | |||
| 47146a6ea2 | |||
| 98d56f4673 |
@@ -1,7 +1,7 @@
|
|||||||
# Custos Domi — core (public)
|
# Custos Domi — core (public)
|
||||||
|
|
||||||
Custos (Latin: guardian) is a local-first password and secret manager in the Domi ecosystem.
|
Custos (Latin: guardian) is a local-first password and secret manager in the Domi ecosystem.
|
||||||
This repository is the **public, MPL-2.0 core**: everything that touches plaintext or keys.
|
This repository is the **public, CPAL-1.0 core** (MPL-2.0 before v0.20.0): everything that touches plaintext or keys.
|
||||||
The Windows app lives in the private `Custos` repo and depends on this one by git tag.
|
The Windows app lives in the private `Custos` repo and depends on this one by git tag.
|
||||||
|
|
||||||
## Layout
|
## Layout
|
||||||
|
|||||||
Generated
+14
-13
@@ -329,14 +329,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-browser"
|
name = "custos-browser"
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-gen"
|
name = "custos-gen"
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-vault",
|
"custos-vault",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
@@ -348,7 +348,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-kdbx"
|
name = "custos-kdbx"
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"argon2",
|
"argon2",
|
||||||
@@ -369,7 +369,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-keys"
|
name = "custos-keys"
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-vault",
|
"custos-vault",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
@@ -382,7 +382,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-native"
|
name = "custos-native"
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-browser",
|
"custos-browser",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -392,11 +392,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-qr"
|
name = "custos-qr"
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-seal"
|
name = "custos-seal"
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chacha20poly1305",
|
"chacha20poly1305",
|
||||||
"hkdf",
|
"hkdf",
|
||||||
@@ -409,7 +409,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-share"
|
name = "custos-share"
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argon2",
|
"argon2",
|
||||||
"chacha20poly1305",
|
"chacha20poly1305",
|
||||||
@@ -426,7 +426,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-sign"
|
name = "custos-sign"
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blake2 0.10.6",
|
"blake2 0.10.6",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
@@ -446,12 +446,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-team"
|
name = "custos-team"
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-seal",
|
"custos-seal",
|
||||||
"custos-sign",
|
"custos-sign",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
|
"hmac 0.13.0",
|
||||||
"minisign-verify",
|
"minisign-verify",
|
||||||
"rand 0.10.3",
|
"rand 0.10.3",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -463,7 +464,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-totp"
|
name = "custos-totp"
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-vault",
|
"custos-vault",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
@@ -476,7 +477,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-vault"
|
name = "custos-vault"
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argon2",
|
"argon2",
|
||||||
"bip39",
|
"bip39",
|
||||||
@@ -502,7 +503,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-wasm"
|
name = "custos-wasm"
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-qr",
|
"custos-qr",
|
||||||
"custos-seal",
|
"custos-seal",
|
||||||
|
|||||||
+2
-2
@@ -3,9 +3,9 @@ resolver = "3"
|
|||||||
members = ["crates/*"]
|
members = ["crates/*"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.18.0"
|
version = "0.20.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MPL-2.0"
|
license = "CPAL-1.0"
|
||||||
repository = "https://gitea.marek-novak.cz/mnovak/CustosPublic"
|
repository = "https://gitea.marek-novak.cz/mnovak/CustosPublic"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
|||||||
@@ -1,373 +1,168 @@
|
|||||||
Mozilla Public License Version 2.0
|
Common Public Attribution License Version 1.0 (CPAL)
|
||||||
==================================
|
|
||||||
|
|
||||||
1. Definitions
|
1. “Definitions”
|
||||||
--------------
|
|
||||||
|
|
||||||
1.1. "Contributor"
|
1.0.1 “Commercial Use” means distribution or otherwise making the Covered Code available to a third party.
|
||||||
means each individual or legal entity that creates, contributes to
|
|
||||||
the creation of, or owns Covered Software.
|
|
||||||
|
|
||||||
1.2. "Contributor Version"
|
1.1 “Contributor” means each entity that creates or contributes to the creation of Modifications.
|
||||||
means the combination of the Contributions of others (if any) used
|
|
||||||
by a Contributor and that particular Contributor's Contribution.
|
|
||||||
|
|
||||||
1.3. "Contribution"
|
1.2 “Contributor Version” means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor.
|
||||||
means Covered Software of a particular Contributor.
|
|
||||||
|
|
||||||
1.4. "Covered Software"
|
1.3 “Covered Code” means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof.
|
||||||
means Source Code Form to which the initial Contributor has attached
|
|
||||||
the notice in Exhibit A, the Executable Form of such Source Code
|
|
||||||
Form, and Modifications of such Source Code Form, in each case
|
|
||||||
including portions thereof.
|
|
||||||
|
|
||||||
1.5. "Incompatible With Secondary Licenses"
|
1.4 “Electronic Distribution Mechanism” means a mechanism generally accepted in the software development community for the electronic transfer of data.
|
||||||
means
|
|
||||||
|
|
||||||
(a) that the initial Contributor has attached the notice described
|
1.5 “Executable” means Covered Code in any form other than Source Code.
|
||||||
in Exhibit B to the Covered Software; or
|
|
||||||
|
|
||||||
(b) that the Covered Software was made available under the terms of
|
1.6 “Initial Developer” means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A.
|
||||||
version 1.1 or earlier of the License, but not also under the
|
|
||||||
terms of a Secondary License.
|
|
||||||
|
|
||||||
1.6. "Executable Form"
|
1.7 “Larger Work” means a work which combines Covered Code or portions thereof with code not governed by the terms of this License.
|
||||||
means any form of the work other than Source Code Form.
|
|
||||||
|
|
||||||
1.7. "Larger Work"
|
1.8 “License” means this document.
|
||||||
means a work that combines Covered Software with other material, in
|
|
||||||
a separate file or files, that is not Covered Software.
|
|
||||||
|
|
||||||
1.8. "License"
|
1.8.1 “Licensable” means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
|
||||||
means this document.
|
|
||||||
|
|
||||||
1.9. "Licensable"
|
1.9 “Modifications” means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is:
|
||||||
means having the right to grant, to the maximum extent possible,
|
|
||||||
whether at the time of the initial grant or subsequently, any and
|
|
||||||
all of the rights conveyed by this License.
|
|
||||||
|
|
||||||
1.10. "Modifications"
|
A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications.
|
||||||
means any of the following:
|
|
||||||
|
|
||||||
(a) any file in Source Code Form that results from an addition to,
|
B. Any new file that contains any part of the Original Code or previous Modifications.
|
||||||
deletion from, or modification of the contents of Covered
|
|
||||||
Software; or
|
|
||||||
|
|
||||||
(b) any new file in Source Code Form that contains any Covered
|
1.10 “Original Code” means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License.
|
||||||
Software.
|
|
||||||
|
|
||||||
1.11. "Patent Claims" of a Contributor
|
1.10.1 “Patent Claims” means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
|
||||||
means any patent claim(s), including without limitation, method,
|
|
||||||
process, and apparatus claims, in any patent Licensable by such
|
|
||||||
Contributor that would be infringed, but for the grant of the
|
|
||||||
License, by the making, using, selling, offering for sale, having
|
|
||||||
made, import, or transfer of either its Contributions or its
|
|
||||||
Contributor Version.
|
|
||||||
|
|
||||||
1.12. "Secondary License"
|
1.11 “Source Code” means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor’s choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge.
|
||||||
means either the GNU General Public License, Version 2.0, the GNU
|
|
||||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
|
||||||
Public License, Version 3.0, or any later versions of those
|
|
||||||
licenses.
|
|
||||||
|
|
||||||
1.13. "Source Code Form"
|
1.12 “You” (or “Your”) means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, “You” includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
|
||||||
means the form of the work preferred for making modifications.
|
|
||||||
|
|
||||||
1.14. "You" (or "Your")
|
2. Source Code License.
|
||||||
means an individual or a legal entity exercising rights under this
|
|
||||||
License. For legal entities, "You" includes any entity that
|
|
||||||
controls, is controlled by, or is under common control with You. For
|
|
||||||
purposes of this definition, "control" means (a) the power, direct
|
|
||||||
or indirect, to cause the direction or management of such entity,
|
|
||||||
whether by contract or otherwise, or (b) ownership of more than
|
|
||||||
fifty percent (50%) of the outstanding shares or beneficial
|
|
||||||
ownership of such entity.
|
|
||||||
|
|
||||||
2. License Grants and Conditions
|
2.1 The Initial Developer Grant.
|
||||||
--------------------------------
|
The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims:
|
||||||
|
|
||||||
2.1. Grants
|
(a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, and/or as part of a Larger Work; and
|
||||||
|
|
||||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
(b) under Patents Claims infringed by the making, using or selling of Original Code, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Code (or portions thereof).
|
||||||
non-exclusive license:
|
|
||||||
|
|
||||||
(a) under intellectual property rights (other than patent or trademark)
|
(c) the licenses granted in this Section 2.1(a) and (b) are effective on the date Initial Developer first distributes Original Code under the terms of this License.
|
||||||
Licensable by such Contributor to use, reproduce, make available,
|
|
||||||
modify, display, perform, distribute, and otherwise exploit its
|
|
||||||
Contributions, either on an unmodified basis, with Modifications, or
|
|
||||||
as part of a Larger Work; and
|
|
||||||
|
|
||||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
(d) Notwithstanding Section 2.1(b) above, no patent license is granted: 1) for code that You delete from the Original Code; 2) separate from the Original Code; or 3) for infringements caused by: i) the modification of the Original Code or ii) the combination of the Original Code with other software or devices.
|
||||||
for sale, have made, import, and otherwise transfer either its
|
|
||||||
Contributions or its Contributor Version.
|
|
||||||
|
|
||||||
2.2. Effective Date
|
2.2 Contributor Grant.
|
||||||
|
Subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license
|
||||||
|
|
||||||
The licenses granted in Section 2.1 with respect to any Contribution
|
(a) under intellectual property rights (other than patent or trademark) Licensable by Contributor, to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code and/or as part of a Larger Work; and
|
||||||
become effective for each Contribution on the date the Contributor first
|
|
||||||
distributes such Contribution.
|
|
||||||
|
|
||||||
2.3. Limitations on Grant Scope
|
(b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications made by that Contributor (or portions thereof); and 2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
|
||||||
|
|
||||||
The licenses granted in this Section 2 are the only rights granted under
|
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first makes Commercial Use of the Covered Code.
|
||||||
this License. No additional rights or licenses will be implied from the
|
|
||||||
distribution or licensing of Covered Software under this License.
|
(d) Notwithstanding Section 2.2(b) above, no patent license is granted: 1) for any code that Contributor has deleted from the Contributor Version; 2) separate from the Contributor Version; 3) for infringements caused by: i) third party modifications of Contributor Version or ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or 4) under Patent Claims infringed by Covered Code in the absence of Modifications made by that Contributor.
|
||||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
|
||||||
Contributor:
|
3. Distribution Obligations.
|
||||||
|
|
||||||
(a) for any code that a Contributor has removed from Covered Software;
|
3.1 Application of License.
|
||||||
or
|
The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients’ rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5.
|
||||||
|
|
||||||
(b) for infringements caused by: (i) Your and any other third party's
|
3.2 Availability of Source Code.
|
||||||
modifications of Covered Software, or (ii) the combination of its
|
Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party.
|
||||||
Contributions with other software (except as part of its Contributor
|
|
||||||
Version); or
|
3.3 Description of Modifications.
|
||||||
|
You must cause all Covered Code to which You contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code.
|
||||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
|
||||||
its Contributions.
|
3.4 Intellectual Property Matters
|
||||||
|
|
||||||
This License does not grant any rights in the trademarks, service marks,
|
(a) Third Party Claims. If Contributor has knowledge that a license under a third party’s intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled “LEGAL” which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the Modification is made available as described in Section 3.2, Contributor shall promptly modify the LEGAL file in all copies Contributor makes available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained.
|
||||||
or logos of any Contributor (except as may be necessary to comply with
|
|
||||||
the notice requirements in Section 3.4).
|
(b) Contributor APIs. If Contributor’s Modifications include an application programming interface and Contributor has knowledge of patent licenses which are reasonably necessary to implement that API, Contributor must also include this information in the LEGAL file.
|
||||||
|
|
||||||
2.4. Subsequent Licenses
|
(c) Representations. Contributor represents that, except as disclosed pursuant to Section 3.4(a) above, Contributor believes that Contributor’s Modifications are Contributor’s original creation(s) and/or Contributor has sufficient rights to grant the rights conveyed by this License.
|
||||||
|
|
||||||
No Contributor makes additional grants as a result of Your choice to
|
3.5 Required Notices.
|
||||||
distribute the Covered Software under a subsequent version of this
|
You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be likely to look for such a notice. If You created one or more Modification(s) You may add your name as a Contributor to the notice described in Exhibit A. You must also duplicate this License in any documentation for the Source Code where You describe recipients’ rights or ownership rights relating to Covered Code. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
|
||||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
|
||||||
permitted under the terms of Section 3.3).
|
3.6 Distribution of Executable Versions.
|
||||||
|
You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients’ rights relating to the Covered Code. You may distribute the Executable version of Covered Code or ownership rights under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient’s rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer, Original Developer or any Contributor. You hereby agree to indemnify the Initial Developer, Original Developer and every Contributor for any liability incurred by the Initial Developer, Original Developer or such Contributor as a result of any such terms You offer.
|
||||||
2.5. Representation
|
|
||||||
|
3.7 Larger Works.
|
||||||
Each Contributor represents that the Contributor believes its
|
You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code.
|
||||||
Contributions are its original creation(s) or it has sufficient rights
|
|
||||||
to grant the rights to its Contributions conveyed by this License.
|
4. Inability to Comply Due to Statute or Regulation.
|
||||||
|
If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
|
||||||
2.6. Fair Use
|
|
||||||
|
5. Application of this License.
|
||||||
This License is not intended to limit any rights You have under
|
This License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code.
|
||||||
applicable copyright doctrines of fair use, fair dealing, or other
|
|
||||||
equivalents.
|
6. Versions of the License.
|
||||||
|
|
||||||
2.7. Conditions
|
6.1 New Versions.
|
||||||
|
Socialtext, Inc. (“Socialtext”) may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number.
|
||||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
|
||||||
in Section 2.1.
|
6.2 Effect of New Versions.
|
||||||
|
Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Socialtext. No one other than Socialtext has the right to modify the terms applicable to Covered Code created under this License.
|
||||||
3. Responsibilities
|
|
||||||
-------------------
|
6.3 Derivative Works.
|
||||||
|
If You create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), You must (a) rename Your license so that the phrases “Socialtext”, “CPAL” or any confusingly similar phrase do not appear in your license (except to note that your license differs from this License) and (b) otherwise make it clear that Your version of the license contains terms which differ from the CPAL. (Filling in the name of the Initial Developer, Original Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.)
|
||||||
3.1. Distribution of Source Form
|
|
||||||
|
7. DISCLAIMER OF WARRANTY.
|
||||||
All distribution of Covered Software in Source Code Form, including any
|
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS” BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER, ORIGINAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
|
||||||
Modifications that You create or to which You contribute, must be under
|
|
||||||
the terms of this License. You must inform recipients that the Source
|
8. TERMINATION.
|
||||||
Code Form of the Covered Software is governed by the terms of this
|
|
||||||
License, and how they can obtain a copy of this License. You may not
|
8.1 This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
|
||||||
attempt to alter or restrict the recipients' rights in the Source Code
|
|
||||||
Form.
|
8.2 If You initiate litigation by asserting a patent infringement claim (excluding declatory judgment actions) against Initial Developer, Original Developer or a Contributor (the Initial Developer, Original Developer or Contributor against whom You file such action is referred to as “Participant”) alleging that:
|
||||||
|
|
||||||
3.2. Distribution of Executable Form
|
(a) such Participant’s Contributor Version directly or indirectly infringes any patent, then any and all rights granted by such Participant to You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively, unless if within 60 days after receipt of notice You either: (i) agree in writing to pay Participant a mutually agreeable reasonable royalty for Your past and future use of Modifications made by such Participant, or (ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant. If within 60 days of notice, a reasonable royalty and payment arrangement are not mutually agreed upon in writing by the parties or the litigation claim is not withdrawn, the rights granted by Participant to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration of the 60 day notice period specified above.
|
||||||
|
|
||||||
If You distribute Covered Software in Executable Form then:
|
(b) any software, hardware, or device, other than such Participant’s Contributor Version, directly or indirectly infringes any patent, then any rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are revoked effective as of the date You first made, used, sold, distributed, or had made, Modifications made by that Participant.
|
||||||
|
|
||||||
(a) such Covered Software must also be made available in Source Code
|
8.3 If You assert a patent infringement claim against Participant alleging that such Participant’s Contributor Version directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license.
|
||||||
Form, as described in Section 3.1, and You must inform recipients of
|
|
||||||
the Executable Form how they can obtain a copy of such Source Code
|
8.4 In the event of termination under Sections 8.1 or 8.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or any distributor hereunder prior to termination shall survive termination.
|
||||||
Form by reasonable means in a timely manner, at a charge no more
|
|
||||||
than the cost of distribution to the recipient; and
|
9. LIMITATION OF LIABILITY.
|
||||||
|
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ORIGINAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY’S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
|
||||||
(b) You may distribute such Executable Form under the terms of this
|
|
||||||
License, or sublicense it under different terms, provided that the
|
10. U.S. GOVERNMENT END USERS.
|
||||||
license for the Executable Form does not attempt to limit or alter
|
The Covered Code is a “commercial item,” as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of “commercial computer software” and “commercial computer software documentation,” as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein.
|
||||||
the recipients' rights in the Source Code Form under this License.
|
|
||||||
|
11. MISCELLANEOUS.
|
||||||
3.3. Distribution of a Larger Work
|
This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in the United States of America, any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California, with venue lying in Santa Clara County, California, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys’ fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License.
|
||||||
|
|
||||||
You may create and distribute a Larger Work under terms of Your choice,
|
12. RESPONSIBILITY FOR CLAIMS.
|
||||||
provided that You also comply with the requirements of this License for
|
As between Initial Developer, Original Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer, Original Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
|
||||||
the Covered Software. If the Larger Work is a combination of Covered
|
|
||||||
Software with a work governed by one or more Secondary Licenses, and the
|
13. MULTIPLE-LICENSED CODE.
|
||||||
Covered Software is not Incompatible With Secondary Licenses, this
|
Initial Developer may designate portions of the Covered Code as Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits you to utilize portions of the Covered Code under Your choice of the CPAL or the alternative licenses, if any, specified by the Initial Developer in the file described in Exhibit A.
|
||||||
License permits You to additionally distribute such Covered Software
|
|
||||||
under the terms of such Secondary License(s), so that the recipient of
|
14. ADDITIONAL TERM: ATTRIBUTION
|
||||||
the Larger Work may, at their option, further distribute the Covered
|
|
||||||
Software under the terms of either this License or such Secondary
|
(a) As a modest attribution to the organizer of the development of the Original Code (“Original Developer”), in the hope that its promotional value may help justify the time, money and effort invested in writing the Original Code, the Original Developer may include in Exhibit B (“Attribution Information”) a requirement that each time an Executable and Source Code or a Larger Work is launched or initially run (which includes initiating a session), a prominent display of the Original Developer’s Attribution Information (as defined below) must occur on the graphic user interface employed by the end user to access such Covered Code (which may include display on a splash screen), if any. The size of the graphic image should be consistent with the size of the other elements of the Attribution Information. If the access by the end user to the Executable and Source Code does not create a graphic user interface for access to the Covered Code, this obligation shall not apply. If the Original Code displays such Attribution Information in a particular form (such as in the form of a splash screen, notice at login, an “about” display, or dedicated attribution area on user interface screens), continued use of such form for that Attribution Information is one way of meeting this requirement for notice.
|
||||||
License(s).
|
|
||||||
|
(b) Attribution information may only include a copyright notice, a brief phrase, graphic image and a URL (“Attribution Information”) and is subject to the Attribution Limits as defined below. For these purposes, prominent shall mean display for sufficient duration to give reasonable notice to the user of the identity of the Original Developer and that if You include Attribution Information or similar information for other parties, You must ensure that the Attribution Information for the Original Developer shall be no less prominent than such Attribution Information or similar information for the other party. For greater certainty, the Original Developer may choose to specify in Exhibit B below that the above attribution requirement only applies to an Executable and Source Code resulting from the Original Code or any Modification, but not a Larger Work. The intent is to provide for reasonably modest attribution, therefore the Original Developer cannot require that You display, at any time, more than the following information as Attribution Information: (a) a copyright notice including the name of the Original Developer; (b) a word or one phrase (not exceeding 10 words); (c) one graphic image provided by the Original Developer; and (d) a URL (collectively, the “Attribution Limits”).
|
||||||
3.4. Notices
|
|
||||||
|
(c) If Exhibit B does not include any Attribution Information, then there are no requirements for You to display any Attribution Information of the Original Developer.
|
||||||
You may not remove or alter the substance of any license notices
|
|
||||||
(including copyright notices, patent notices, disclaimers of warranty,
|
(d) You acknowledge that all trademarks, service marks and/or trade names contained within the Attribution Information distributed with the Covered Code are the exclusive property of their owners and may only be used with the permission of their owners, or under circumstances otherwise permitted by law or as expressly set out in this License.
|
||||||
or limitations of liability) contained within the Source Code Form of
|
|
||||||
the Covered Software, except that You may alter any license notices to
|
15. ADDITIONAL TERM: NETWORK USE.
|
||||||
the extent required to remedy known factual inaccuracies.
|
The term “External Deployment” means the use, distribution, or communication of the Original Code or Modifications in any way such that the Original Code or Modifications may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Code or Modifications as a distribution under section 3.1 and make Source Code available under Section 3.2.
|
||||||
|
|
||||||
3.5. Application of Additional Terms
|
EXHIBIT A. Common Public Attribution License Version 1.0.
|
||||||
|
|
||||||
You may choose to offer, and to charge a fee for, warranty, support,
|
"The contents of this file are subject to the Common Public Attribution License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://opensource.org/license/cpal_1-0. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
||||||
indemnity or liability obligations to one or more recipients of Covered
|
Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
||||||
Software. However, You may do so only on Your own behalf, and not on
|
The Original Code is CustosPublic.
|
||||||
behalf of any Contributor. You must make it absolutely clear that any
|
The Original Developer is the Initial Developer.
|
||||||
such warranty, support, indemnity, or liability obligation is offered by
|
The Initial Developer of the Original Code is Marek Novák. All portions of the code written by Marek Novák are Copyright (c) 2026. All Rights Reserved.
|
||||||
You alone, and You hereby agree to indemnify every Contributor for any
|
Contributor: none."
|
||||||
liability incurred by such Contributor as a result of warranty, support,
|
|
||||||
indemnity or liability terms You offer. You may include additional
|
EXHIBIT B. Attribution Information
|
||||||
disclaimers of warranty and limitations of liability specific to any
|
|
||||||
jurisdiction.
|
Attribution Copyright Notice: Copyright (c) 2026 Marek Novák
|
||||||
|
Attribution Phrase (not exceeding 10 words): Built on Domi
|
||||||
4. Inability to Comply Due to Statute or Regulation
|
Attribution URL: https://aula.marek-novak.cz
|
||||||
---------------------------------------------------
|
Graphic Image as provided in the Covered Code, if any: none.
|
||||||
|
Display of Attribution Information is required in Larger Works which are defined in the CPAL as a work which combines Covered Code or portions thereof with code not governed by the terms of the CPAL.
|
||||||
If it is impossible for You to comply with any of the terms of this
|
|
||||||
License with respect to some or all of the Covered Software due to
|
|
||||||
statute, judicial order, or regulation then You must: (a) comply with
|
|
||||||
the terms of this License to the maximum extent possible; and (b)
|
|
||||||
describe the limitations and the code they affect. Such description must
|
|
||||||
be placed in a text file included with all distributions of the Covered
|
|
||||||
Software under this License. Except to the extent prohibited by statute
|
|
||||||
or regulation, such description must be sufficiently detailed for a
|
|
||||||
recipient of ordinary skill to be able to understand it.
|
|
||||||
|
|
||||||
5. Termination
|
|
||||||
--------------
|
|
||||||
|
|
||||||
5.1. The rights granted under this License will terminate automatically
|
|
||||||
if You fail to comply with any of its terms. However, if You become
|
|
||||||
compliant, then the rights granted under this License from a particular
|
|
||||||
Contributor are reinstated (a) provisionally, unless and until such
|
|
||||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
|
||||||
ongoing basis, if such Contributor fails to notify You of the
|
|
||||||
non-compliance by some reasonable means prior to 60 days after You have
|
|
||||||
come back into compliance. Moreover, Your grants from a particular
|
|
||||||
Contributor are reinstated on an ongoing basis if such Contributor
|
|
||||||
notifies You of the non-compliance by some reasonable means, this is the
|
|
||||||
first time You have received notice of non-compliance with this License
|
|
||||||
from such Contributor, and You become compliant prior to 30 days after
|
|
||||||
Your receipt of the notice.
|
|
||||||
|
|
||||||
5.2. If You initiate litigation against any entity by asserting a patent
|
|
||||||
infringement claim (excluding declaratory judgment actions,
|
|
||||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
|
||||||
directly or indirectly infringes any patent, then the rights granted to
|
|
||||||
You by any and all Contributors for the Covered Software under Section
|
|
||||||
2.1 of this License shall terminate.
|
|
||||||
|
|
||||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
|
||||||
end user license agreements (excluding distributors and resellers) which
|
|
||||||
have been validly granted by You or Your distributors under this License
|
|
||||||
prior to termination shall survive termination.
|
|
||||||
|
|
||||||
************************************************************************
|
|
||||||
* *
|
|
||||||
* 6. Disclaimer of Warranty *
|
|
||||||
* ------------------------- *
|
|
||||||
* *
|
|
||||||
* Covered Software is provided under this License on an "as is" *
|
|
||||||
* basis, without warranty of any kind, either expressed, implied, or *
|
|
||||||
* statutory, including, without limitation, warranties that the *
|
|
||||||
* Covered Software is free of defects, merchantable, fit for a *
|
|
||||||
* particular purpose or non-infringing. The entire risk as to the *
|
|
||||||
* quality and performance of the Covered Software is with You. *
|
|
||||||
* Should any Covered Software prove defective in any respect, You *
|
|
||||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
|
||||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
|
||||||
* essential part of this License. No use of any Covered Software is *
|
|
||||||
* authorized under this License except under this disclaimer. *
|
|
||||||
* *
|
|
||||||
************************************************************************
|
|
||||||
|
|
||||||
************************************************************************
|
|
||||||
* *
|
|
||||||
* 7. Limitation of Liability *
|
|
||||||
* -------------------------- *
|
|
||||||
* *
|
|
||||||
* Under no circumstances and under no legal theory, whether tort *
|
|
||||||
* (including negligence), contract, or otherwise, shall any *
|
|
||||||
* Contributor, or anyone who distributes Covered Software as *
|
|
||||||
* permitted above, be liable to You for any direct, indirect, *
|
|
||||||
* special, incidental, or consequential damages of any character *
|
|
||||||
* including, without limitation, damages for lost profits, loss of *
|
|
||||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
|
||||||
* and all other commercial damages or losses, even if such party *
|
|
||||||
* shall have been informed of the possibility of such damages. This *
|
|
||||||
* limitation of liability shall not apply to liability for death or *
|
|
||||||
* personal injury resulting from such party's negligence to the *
|
|
||||||
* extent applicable law prohibits such limitation. Some *
|
|
||||||
* jurisdictions do not allow the exclusion or limitation of *
|
|
||||||
* incidental or consequential damages, so this exclusion and *
|
|
||||||
* limitation may not apply to You. *
|
|
||||||
* *
|
|
||||||
************************************************************************
|
|
||||||
|
|
||||||
8. Litigation
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Any litigation relating to this License may be brought only in the
|
|
||||||
courts of a jurisdiction where the defendant maintains its principal
|
|
||||||
place of business and such litigation shall be governed by laws of that
|
|
||||||
jurisdiction, without reference to its conflict-of-law provisions.
|
|
||||||
Nothing in this Section shall prevent a party's ability to bring
|
|
||||||
cross-claims or counter-claims.
|
|
||||||
|
|
||||||
9. Miscellaneous
|
|
||||||
----------------
|
|
||||||
|
|
||||||
This License represents the complete agreement concerning the subject
|
|
||||||
matter hereof. If any provision of this License is held to be
|
|
||||||
unenforceable, such provision shall be reformed only to the extent
|
|
||||||
necessary to make it enforceable. Any law or regulation which provides
|
|
||||||
that the language of a contract shall be construed against the drafter
|
|
||||||
shall not be used to construe this License against a Contributor.
|
|
||||||
|
|
||||||
10. Versions of the License
|
|
||||||
---------------------------
|
|
||||||
|
|
||||||
10.1. New Versions
|
|
||||||
|
|
||||||
Mozilla Foundation is the license steward. Except as provided in Section
|
|
||||||
10.3, no one other than the license steward has the right to modify or
|
|
||||||
publish new versions of this License. Each version will be given a
|
|
||||||
distinguishing version number.
|
|
||||||
|
|
||||||
10.2. Effect of New Versions
|
|
||||||
|
|
||||||
You may distribute the Covered Software under the terms of the version
|
|
||||||
of the License under which You originally received the Covered Software,
|
|
||||||
or under the terms of any subsequent version published by the license
|
|
||||||
steward.
|
|
||||||
|
|
||||||
10.3. Modified Versions
|
|
||||||
|
|
||||||
If you create software not governed by this License, and you want to
|
|
||||||
create a new license for such software, you may create and use a
|
|
||||||
modified version of this License if you rename the license and remove
|
|
||||||
any references to the name of the license steward (except to note that
|
|
||||||
such modified license differs from this License).
|
|
||||||
|
|
||||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
|
||||||
Licenses
|
|
||||||
|
|
||||||
If You choose to distribute Source Code Form that is Incompatible With
|
|
||||||
Secondary Licenses under the terms of this version of the License, the
|
|
||||||
notice described in Exhibit B of this License must be attached.
|
|
||||||
|
|
||||||
Exhibit A - Source Code Form License Notice
|
|
||||||
-------------------------------------------
|
|
||||||
|
|
||||||
This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
If it is not possible or desirable to put the notice in a particular
|
|
||||||
file, then You may include the notice in a location (such as a LICENSE
|
|
||||||
file in a relevant directory) where a recipient would be likely to look
|
|
||||||
for such a notice.
|
|
||||||
|
|
||||||
You may add additional accurate notices of copyright ownership.
|
|
||||||
|
|
||||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
|
||||||
---------------------------------------------------------
|
|
||||||
|
|
||||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
|
||||||
defined by the Mozilla Public License, v. 2.0.
|
|
||||||
@@ -21,4 +21,20 @@ for what it does and does not protect. Report vulnerabilities as described in [`
|
|||||||
cargo test --workspace
|
cargo test --workspace
|
||||||
```
|
```
|
||||||
|
|
||||||
Licence: MPL-2.0. The memorable-password words come from the EFF wordlist (CC BY 3.0 US), filtered with the ESDB/SCOWL English dictionary (see `crates/custos-gen/wordlists/SOURCES.md`).
|
## Licence
|
||||||
|
|
||||||
|
CustosPublic is licensed under the **Common Public Attribution License 1.0** (SPDX `CPAL-1.0`), from v0.20.0 on: see
|
||||||
|
[LICENSE](LICENSE). Versions before this change (up to and including v0.19.1) stay available under MPL-2.0 to those
|
||||||
|
who received them under it.
|
||||||
|
|
||||||
|
**Attribution (Exhibit B).** Anyone who redistributes CustosPublic, or software built on it, must show this credit
|
||||||
|
where CPAL-1.0 §14 asks for it:
|
||||||
|
|
||||||
|
| | |
|
||||||
|
| :-- | :-- |
|
||||||
|
| Attribution Copyright Notice | Copyright (c) 2026 Marek Novák |
|
||||||
|
| Attribution Phrase | Built on Domi |
|
||||||
|
| Attribution URL | https://aula.marek-novak.cz |
|
||||||
|
| Graphic Image | none |
|
||||||
|
|
||||||
|
Third-party parts keep their own licences. The memorable-password words come from the EFF wordlist (CC BY 3.0 US), filtered with the ESDB/SCOWL English dictionary (see `crates/custos-gen/wordlists/SOURCES.md`).
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ custos-seal = { path = "../custos-seal" }
|
|||||||
custos-sign = { path = "../custos-sign" }
|
custos-sign = { path = "../custos-sign" }
|
||||||
ed25519-dalek = { version = "2", default-features = false, features = ["std", "zeroize"] }
|
ed25519-dalek = { version = "2", default-features = false, features = ["std", "zeroize"] }
|
||||||
sha2.workspace = true
|
sha2.workspace = true
|
||||||
|
hmac.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
data-encoding.workspace = true
|
data-encoding.workspace = true
|
||||||
|
|||||||
@@ -244,8 +244,13 @@ pub fn evaluate(policy: &Policy, roster: &[RosterMember], env: &str, author: &st
|
|||||||
ignored.push(a.clone());
|
ignored.push(a.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// `others` needs to know who the author is (core 0.18.1): an empty author, or one no member is, would let the
|
||||||
|
// author approve their own release under a name the rule cannot see.
|
||||||
|
let unknown_author = rule.others && roster.len() >= 2 && !roster.iter().any(|m| m.is(author));
|
||||||
let verdict = if rule.approvals == 0 {
|
let verdict = if rule.approvals == 0 {
|
||||||
Verdict::Allowed(KeyRole::Test)
|
Verdict::Allowed(KeyRole::Test)
|
||||||
|
} else if unknown_author {
|
||||||
|
Verdict::Unsatisfiable("the release's author is not a member the team knows, so the rule cannot exclude them")
|
||||||
} else if counted.len() >= rule.approvals as usize {
|
} else if counted.len() >= rule.approvals as usize {
|
||||||
Verdict::Allowed(KeyRole::Release)
|
Verdict::Allowed(KeyRole::Release)
|
||||||
} else if eligible.len() < rule.approvals as usize {
|
} else if eligible.len() < rule.approvals as usize {
|
||||||
@@ -278,5 +283,8 @@ pub fn may_approve(
|
|||||||
if rule.others && roster.len() >= 2 && me.is(author) {
|
if rule.others && roster.len() >= 2 && me.is(author) {
|
||||||
return Err(TeamError::NotEligible("the release's author may not approve it here"));
|
return Err(TeamError::NotEligible("the release's author may not approve it here"));
|
||||||
}
|
}
|
||||||
|
if rule.approvals > 0 && rule.others && roster.len() >= 2 && !roster.iter().any(|m| m.is(author)) {
|
||||||
|
return Err(TeamError::NotEligible("the release's author is not a member the team knows"));
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ pub struct SignReply {
|
|||||||
pub key: ReplyKey,
|
pub key: ReplyKey,
|
||||||
pub signer: ReplySigner,
|
pub signer: ReplySigner,
|
||||||
pub proof: Proof,
|
pub proof: Proof,
|
||||||
|
/// The deployment ticket (core 0.18.1): 32 random bytes, base64, for the `mac` of this deployment's
|
||||||
|
/// `target.request`s. Secret: it travels only inside the sealed reply; never log it.
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub ticket: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SignReply {
|
impl SignReply {
|
||||||
|
|||||||
@@ -258,6 +258,9 @@ pub struct TargetRequest {
|
|||||||
pub deployment: String,
|
pub deployment: String,
|
||||||
pub public: [u8; 32],
|
pub public: [u8; 32],
|
||||||
pub expires: u64,
|
pub expires: u64,
|
||||||
|
/// HMAC-SHA256 with the deployment's ticket (core 0.18.1): only the Fabrica that opened the signing reply has the
|
||||||
|
/// ticket, so only it can ask for the deployment's credentials.
|
||||||
|
pub mac: [u8; 32],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
@@ -272,9 +275,50 @@ struct TargetJson {
|
|||||||
#[serde(rename = "pub")]
|
#[serde(rename = "pub")]
|
||||||
public: String,
|
public: String,
|
||||||
expires: u64,
|
expires: u64,
|
||||||
|
mac: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The domain of a target request's MAC.
|
||||||
|
pub const TARGET_MAC_DOMAIN: &[u8] = b"custos team target v1\0";
|
||||||
|
|
||||||
impl TargetRequest {
|
impl TargetRequest {
|
||||||
|
/// The text the MAC covers: the canonical request without `mac`.
|
||||||
|
fn unsigned(&self) -> String {
|
||||||
|
let mut o = String::with_capacity(256);
|
||||||
|
o.push_str("{\"v\":1,\"op\":\"target.request\",\"team\":");
|
||||||
|
canon::string(&mut o, &self.team);
|
||||||
|
o.push_str(",\"id\":");
|
||||||
|
canon::string(&mut o, &self.id);
|
||||||
|
o.push_str(",\"target\":");
|
||||||
|
canon::string(&mut o, &self.target);
|
||||||
|
o.push_str(",\"deployment\":");
|
||||||
|
canon::string(&mut o, &self.deployment);
|
||||||
|
o.push_str(",\"pub\":");
|
||||||
|
canon::string(&mut o, &b64(&self.public));
|
||||||
|
o.push_str(",\"expires\":");
|
||||||
|
o.push_str(&self.expires.to_string());
|
||||||
|
o
|
||||||
|
}
|
||||||
|
|
||||||
|
fn mac_over(&self, ticket: &[u8; 32]) -> hmac::Hmac<sha2::Sha256> {
|
||||||
|
use hmac::KeyInit;
|
||||||
|
let mut m = <hmac::Hmac<sha2::Sha256> as KeyInit>::new_from_slice(ticket).expect("any key length");
|
||||||
|
hmac::Mac::update(&mut m, TARGET_MAC_DOMAIN);
|
||||||
|
hmac::Mac::update(&mut m, self.unsigned().as_bytes());
|
||||||
|
m
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets `mac` with the deployment's ticket (from the sealed `sign.reply`).
|
||||||
|
pub fn sign_with(mut self, ticket: &[u8; 32]) -> TargetRequest {
|
||||||
|
self.mac = hmac::Mac::finalize(self.mac_over(ticket)).into_bytes().into();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether `mac` was made with this ticket (constant time).
|
||||||
|
pub fn mac_ok(&self, ticket: &[u8; 32]) -> bool {
|
||||||
|
hmac::Mac::verify_slice(self.mac_over(ticket), &self.mac).is_ok()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn canonical(&self) -> String {
|
pub fn canonical(&self) -> String {
|
||||||
let mut o = String::with_capacity(256);
|
let mut o = String::with_capacity(256);
|
||||||
o.push_str("{\"v\":1,\"op\":\"target.request\",\"team\":");
|
o.push_str("{\"v\":1,\"op\":\"target.request\",\"team\":");
|
||||||
@@ -289,6 +333,8 @@ impl TargetRequest {
|
|||||||
canon::string(&mut o, &b64(&self.public));
|
canon::string(&mut o, &b64(&self.public));
|
||||||
o.push_str(",\"expires\":");
|
o.push_str(",\"expires\":");
|
||||||
o.push_str(&self.expires.to_string());
|
o.push_str(&self.expires.to_string());
|
||||||
|
o.push_str(",\"mac\":");
|
||||||
|
canon::string(&mut o, &b64(&self.mac));
|
||||||
o.push('}');
|
o.push('}');
|
||||||
o
|
o
|
||||||
}
|
}
|
||||||
@@ -309,6 +355,9 @@ impl TargetRequest {
|
|||||||
deployment: j.deployment,
|
deployment: j.deployment,
|
||||||
public: pub_key(&j.public)?,
|
public: pub_key(&j.public)?,
|
||||||
expires: j.expires,
|
expires: j.expires,
|
||||||
|
mac: unb64(&j.mac)
|
||||||
|
.and_then(|m| m.try_into().ok())
|
||||||
|
.ok_or(TeamError::Invalid("mac is not base64 of 32 bytes"))?,
|
||||||
};
|
};
|
||||||
if !id_ok(&r.team) || !id_ok(&r.id) || !lower_hex(&r.target, 16) || !lower_hex(&r.deployment, 64) {
|
if !id_ok(&r.team) || !id_ok(&r.id) || !lower_hex(&r.target, 16) || !lower_hex(&r.deployment, 64) {
|
||||||
return Err(TeamError::Invalid("team, id, target and deployment are hex ids"));
|
return Err(TeamError::Invalid("team, id, target and deployment are hex ids"));
|
||||||
|
|||||||
@@ -58,6 +58,12 @@ fn expected(n: usize, env: &str, author_is_member: bool, set: &[String]) -> Verd
|
|||||||
}
|
}
|
||||||
"production" => {
|
"production" => {
|
||||||
// "1 by someone other than the release author when the team has 2+ members"
|
// "1 by someone other than the release author when the team has 2+ members"
|
||||||
|
// ... and the rule must know the author: someone no member is (or nobody named) cannot be excluded.
|
||||||
|
if n >= 2 && !author_is_member {
|
||||||
|
return Verdict::Unsatisfiable(
|
||||||
|
"the release's author is not a member the team knows, so the rule cannot exclude them",
|
||||||
|
);
|
||||||
|
}
|
||||||
let author_excluded = n >= 2 && author_is_member;
|
let author_excluded = n >= 2 && author_is_member;
|
||||||
let counted = distinct.iter().filter(|m| !(author_excluded && m.as_str() == id(0))).count();
|
let counted = distinct.iter().filter(|m| !(author_excluded && m.as_str() == id(0))).count();
|
||||||
if counted >= 1 { Verdict::Allowed(KeyRole::Release) } else { Verdict::Need(1) }
|
if counted >= 1 { Verdict::Allowed(KeyRole::Release) } else { Verdict::Need(1) }
|
||||||
@@ -125,11 +131,14 @@ fn several_approvals_others_and_approver_lists() {
|
|||||||
evaluate(&p, &three, "production", "mnovak", &[id(1), id(2)]).verdict,
|
evaluate(&p, &three, "production", "mnovak", &[id(1), id(2)]).verdict,
|
||||||
Verdict::Allowed(KeyRole::Release)
|
Verdict::Allowed(KeyRole::Release)
|
||||||
);
|
);
|
||||||
// Someone not named as the author (a release by a non-member): every member counts.
|
// Someone no member is, or nobody named: the rule cannot exclude the author, so it refuses (core 0.18.1).
|
||||||
assert_eq!(
|
for author in ["stranger", ""] {
|
||||||
evaluate(&p, &three, "production", "stranger", &[id(0), id(1)]).verdict,
|
assert!(matches!(
|
||||||
Verdict::Allowed(KeyRole::Release)
|
evaluate(&p, &three, "production", author, &[id(0), id(1)]).verdict,
|
||||||
);
|
Verdict::Unsatisfiable(_)
|
||||||
|
));
|
||||||
|
assert!(matches!(may_approve(&p, &three, "production", author, &id(1)), Err(TeamError::NotEligible(_))));
|
||||||
|
}
|
||||||
|
|
||||||
// Only member 1 may approve staging.
|
// Only member 1 may approve staging.
|
||||||
p.set_rule(EnvRule { env: "staging".into(), approvals: 1, others: false, approvers: vec![id(1)] }).unwrap();
|
p.set_rule(EnvRule { env: "staging".into(), approvals: 1, others: false, approvers: vec![id(1)] }).unwrap();
|
||||||
|
|||||||
@@ -829,6 +829,29 @@ mod tests {
|
|||||||
assert_eq!(full.standing_rules()[0].uses, u64::MAX);
|
assert_eq!(full.standing_rules()[0].uses, u64::MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_broken_android_grant_makes_the_vault_refuse_to_open() {
|
||||||
|
let mut v = vault();
|
||||||
|
v.android_grant_set(&["mnovak/*".to_string()], "Marek Novak", "CZ", NOW).unwrap();
|
||||||
|
let json = body_json(&v);
|
||||||
|
assert!(Vault::open(&with_body(&v, &json), &SecretString::from("pw")).is_ok());
|
||||||
|
let from = r#""repos":["mnovak/*"],"o":"Marek Novak","c":"CZ""#;
|
||||||
|
assert!(json.contains(from), "{json}");
|
||||||
|
for to in [
|
||||||
|
r#""repos":["*/*"],"o":"Marek Novak","c":"CZ""#,
|
||||||
|
r#""repos":["*"],"o":"Marek Novak","c":"CZ""#,
|
||||||
|
r#""repos":[],"o":"Marek Novak","c":"CZ""#,
|
||||||
|
r#""repos":["mnovak/*","mnovak/*"],"o":"Marek Novak","c":"CZ""#,
|
||||||
|
r#""repos":["mnovak/*"],"o":"","c":"CZ""#,
|
||||||
|
r#""repos":["mnovak/*"],"o":"Marek Novak","c":"Czech""#,
|
||||||
|
r#""repos":["mnovak/*"],"o":"Marek Novak","c":"CZ","made":["Not An Id"]"#,
|
||||||
|
] {
|
||||||
|
let bad = json.replacen(from, to, 1);
|
||||||
|
let r = Vault::open(&with_body(&v, &bad), &SecretString::from("pw"));
|
||||||
|
assert!(matches!(r, Err(Error::Corrupted)), "{to}: {r:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_broken_standing_approval_makes_the_vault_refuse_to_open() {
|
fn a_broken_standing_approval_makes_the_vault_refuse_to_open() {
|
||||||
let v = vault_with_a_standing_approval();
|
let v = vault_with_a_standing_approval();
|
||||||
|
|||||||
@@ -203,6 +203,35 @@ pub struct StandingRule {
|
|||||||
/// At most this many standing approvals in a vault.
|
/// At most this many standing approvals in a vault.
|
||||||
pub const STANDING_MAX: usize = 256;
|
pub const STANDING_MAX: usize = 256;
|
||||||
|
|
||||||
|
/// The Android grant (core 0.19.0, docs/SIGNING.md "The Android grant"): Mark's one answer for every Domi app's
|
||||||
|
/// release APK. It signs an app key's APKs from this PC's pipe, its first signature included, and makes the key when
|
||||||
|
/// the app's first release asks. Nothing in it is secret.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct AndroidGrant {
|
||||||
|
/// `owner/name` or `owner/*`, 1 to [`ANDROID_PATTERNS_MAX`].
|
||||||
|
pub repos: Vec<String>,
|
||||||
|
/// The organisation and country in the certificates of the keys it makes.
|
||||||
|
pub o: String,
|
||||||
|
pub c: String,
|
||||||
|
/// Unix milliseconds: when Mark granted it, or last changed it.
|
||||||
|
pub granted: i64,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub last_used: Option<i64>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub uses: u64,
|
||||||
|
/// The ids of the keys it made, oldest first.
|
||||||
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub made: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The one pipeline the Android grant covers.
|
||||||
|
pub const ANDROID_PIPELINE: &str = "release";
|
||||||
|
/// At most this many repository patterns in the Android grant.
|
||||||
|
pub const ANDROID_PATTERNS_MAX: usize = 64;
|
||||||
|
/// At most this many keys the Android grant remembers making.
|
||||||
|
const ANDROID_MADE_MAX: usize = 256;
|
||||||
|
|
||||||
/// A signature handed back to the build.
|
/// A signature handed back to the build.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct Signed {
|
pub struct Signed {
|
||||||
@@ -269,6 +298,7 @@ pub(crate) struct Store {
|
|||||||
pub(crate) keys: Vec<Key>,
|
pub(crate) keys: Vec<Key>,
|
||||||
pub(crate) audit: Vec<AuditEntry>,
|
pub(crate) audit: Vec<AuditEntry>,
|
||||||
standing: Vec<StandingRule>,
|
standing: Vec<StandingRule>,
|
||||||
|
android: Option<AndroidGrant>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
@@ -303,6 +333,9 @@ pub(crate) struct StoreJson {
|
|||||||
/// Standing approvals (core 0.16.0); absent while there are none.
|
/// Standing approvals (core 0.16.0); absent while there are none.
|
||||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
standing: Vec<StandingRule>,
|
standing: Vec<StandingRule>,
|
||||||
|
/// The Android grant (core 0.19.0); absent while there is none. Older cores ignore and drop it.
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
android: Option<AndroidGrant>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn b64(bytes: &[u8]) -> String {
|
fn b64(bytes: &[u8]) -> String {
|
||||||
@@ -330,7 +363,7 @@ fn unhex8(s: &str) -> Option<[u8; 8]> {
|
|||||||
|
|
||||||
impl Store {
|
impl Store {
|
||||||
pub(crate) fn is_empty(&self) -> bool {
|
pub(crate) fn is_empty(&self) -> bool {
|
||||||
self.keys.is_empty() && self.audit.is_empty() && self.standing.is_empty()
|
self.keys.is_empty() && self.audit.is_empty() && self.standing.is_empty() && self.android.is_none()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn from_json(j: StoreJson) -> Option<Store> {
|
pub(crate) fn from_json(j: StoreJson) -> Option<Store> {
|
||||||
@@ -389,7 +422,10 @@ impl Store {
|
|||||||
if j.standing.len() > STANDING_MAX || !j.standing.iter().all(rule_ok) {
|
if j.standing.len() > STANDING_MAX || !j.standing.iter().all(rule_ok) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(Store { keys, audit: j.audit, standing: j.standing })
|
if j.android.as_ref().is_some_and(|g| !grant_ok(g)) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
Some(Store { keys, audit: j.audit, standing: j.standing, android: j.android })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn json(&self) -> Option<StoreJson> {
|
pub(crate) fn json(&self) -> Option<StoreJson> {
|
||||||
@@ -418,7 +454,12 @@ impl Store {
|
|||||||
repos: k.repos.clone(),
|
repos: k.repos.clone(),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
Some(StoreJson { keys, audit: self.audit.clone(), standing: self.standing.clone() })
|
Some(StoreJson {
|
||||||
|
keys,
|
||||||
|
audit: self.audit.clone(),
|
||||||
|
standing: self.standing.clone(),
|
||||||
|
android: self.android.clone(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get(&self, id: &str) -> Option<&Key> {
|
pub(crate) fn get(&self, id: &str) -> Option<&Key> {
|
||||||
@@ -514,6 +555,64 @@ fn rule_words(r: &StandingRule) -> String {
|
|||||||
format!("{} {} {} pipeline {} {}{targets}", r.repo, r.key, kind_word(r.kind), r.pipeline, via_word(r.via))
|
format!("{} {} {} pipeline {} {}{targets}", r.repo, r.key, kind_word(r.kind), r.pipeline, via_word(r.via))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `owner/name`, each 1 to 64 of `A-Z a-z 0-9 . _ -`: the owner and the name, or `None`.
|
||||||
|
fn repo_parts(repo: &str) -> Option<(&str, &str)> {
|
||||||
|
let part =
|
||||||
|
|x: &str| (1..=64).contains(&x.len()) && x.bytes().all(|b| b.is_ascii_alphanumeric() || b"._-".contains(&b));
|
||||||
|
let (owner, name) = repo.split_once('/')?;
|
||||||
|
(part(owner) && part(name)).then_some((owner, name))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The app key of a repository (core 0.19.0): `mnovak/Culina` is `culina-android` (the name in lower case, `.` and
|
||||||
|
/// `_` as `-`); `None` for anything that is not `owner/name` or an id longer than 64.
|
||||||
|
pub fn android_key_id(repo: &str) -> Option<String> {
|
||||||
|
let (_, name) = repo_parts(repo)?;
|
||||||
|
let id: String = name.chars().map(|c| if c == '.' || c == '_' { '-' } else { c.to_ascii_lowercase() }).collect();
|
||||||
|
let id = format!("{id}-android");
|
||||||
|
(id.len() <= 64).then_some(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A pattern of the Android grant: `owner/name`, or `owner/*` for every repository of that owner.
|
||||||
|
fn grant_pattern_ok(p: &str) -> bool {
|
||||||
|
match p.strip_suffix("/*") {
|
||||||
|
Some(owner) => repo_parts(&format!("{owner}/x")).is_some(),
|
||||||
|
None => repo_parts(p).is_some(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn grant_covers(g: &AndroidGrant, repo: &str) -> bool {
|
||||||
|
let Some((owner, _)) = repo_parts(repo) else { return false };
|
||||||
|
g.repos.iter().any(|p| p == repo || p.strip_suffix("/*") == Some(owner))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The certificate's O (1 to 64, no control characters) and C (two ASCII capitals) for the keys the grant makes.
|
||||||
|
fn grant_subject_ok(o: &str, c: &str) -> bool {
|
||||||
|
(1..=64).contains(&o.chars().count())
|
||||||
|
&& !o.chars().any(char::is_control)
|
||||||
|
&& o.trim() == o
|
||||||
|
&& c.len() == 2
|
||||||
|
&& c.bytes().all(|b| b.is_ascii_uppercase())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A stored grant is what [`Vault::android_grant_set`] could have written; anything else makes the vault refuse to
|
||||||
|
/// open.
|
||||||
|
fn grant_ok(g: &AndroidGrant) -> bool {
|
||||||
|
let id_ok = |id: &String| {
|
||||||
|
(1..=64).contains(&id.len()) && id.bytes().all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-')
|
||||||
|
};
|
||||||
|
(1..=ANDROID_PATTERNS_MAX).contains(&g.repos.len())
|
||||||
|
&& g.repos.iter().all(|p| grant_pattern_ok(p))
|
||||||
|
&& g.repos.iter().enumerate().all(|(i, p)| !g.repos[..i].contains(p))
|
||||||
|
&& grant_subject_ok(&g.o, &g.c)
|
||||||
|
&& g.made.len() <= ANDROID_MADE_MAX
|
||||||
|
&& g.made.iter().all(id_ok)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What the grant says, for the security audit: names only.
|
||||||
|
fn grant_words(g: &AndroidGrant) -> String {
|
||||||
|
format!("Android releases: {} pipeline {ANDROID_PIPELINE}, keys made on first use", g.repos.join(", "))
|
||||||
|
}
|
||||||
|
|
||||||
fn in_scope(list: &[String], what: &str) -> bool {
|
fn in_scope(list: &[String], what: &str) -> bool {
|
||||||
list.iter().any(|x| x == "*" || x == what)
|
list.iter().any(|x| x == "*" || x == what)
|
||||||
}
|
}
|
||||||
@@ -846,7 +945,9 @@ impl Vault {
|
|||||||
return Err(r);
|
return Err(r);
|
||||||
}
|
}
|
||||||
let rule = self.standing_rule_for(req, now).map(|r| r.id);
|
let rule = self.standing_rule_for(req, now).map(|r| r.id);
|
||||||
if approval == Approval::Standing && rule.is_none() {
|
// A standing approval first; the Android grant only where none fits (core 0.19.0).
|
||||||
|
let by_grant = approval == Approval::Standing && rule.is_none() && self.android_grant_fits(req, now);
|
||||||
|
if approval == Approval::Standing && rule.is_none() && !by_grant {
|
||||||
let r = Refusal::NeedsApproval(req.key.clone());
|
let r = Refusal::NeedsApproval(req.key.clone());
|
||||||
self.signing_record(req, Outcome::Refused, Some(r.to_string()), None, now);
|
self.signing_record(req, Outcome::Refused, Some(r.to_string()), None, now);
|
||||||
return Err(r);
|
return Err(r);
|
||||||
@@ -902,6 +1003,10 @@ impl Vault {
|
|||||||
r.uses = r.uses.saturating_add(1);
|
r.uses = r.uses.saturating_add(1);
|
||||||
r.last_used = Some(now);
|
r.last_used = Some(now);
|
||||||
}
|
}
|
||||||
|
if by_grant && let Some(g) = self.signing.android.as_mut() {
|
||||||
|
g.uses = g.uses.saturating_add(1);
|
||||||
|
g.last_used = Some(now);
|
||||||
|
}
|
||||||
Ok(Signed { bytes, sha256 })
|
Ok(Signed { bytes, sha256 })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1091,6 +1196,131 @@ impl Vault {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The Android grant, if Mark gave it (core 0.19.0, docs/SIGNING.md "The Android grant").
|
||||||
|
pub fn android_grant(&self) -> Option<AndroidGrant> {
|
||||||
|
self.signing.android.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Stores the Android grant, or replaces its patterns and subject (its counts and the keys it made stay), and
|
||||||
|
/// writes `standing-granted`. Refused while *Sign only with a card* is ticked. Call it only from Mark's own
|
||||||
|
/// click. The caller saves.
|
||||||
|
pub fn android_grant_set(&mut self, repos: &[String], o: &str, c: &str, now: i64) -> Result<AndroidGrant, Error> {
|
||||||
|
if self.security.is_ticked(crate::security::Item::CardSigning) {
|
||||||
|
return Err(Error::Signing("Sign only with a card is ticked".into()));
|
||||||
|
}
|
||||||
|
let mut patterns: Vec<String> = Vec::new();
|
||||||
|
for p in repos.iter().map(|p| p.trim()).filter(|p| !p.is_empty()) {
|
||||||
|
if !grant_pattern_ok(p) {
|
||||||
|
return Err(Error::Signing(format!(
|
||||||
|
"`{p}` is not a repository (owner/name) or every repository of an owner (owner/*)"
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
if !patterns.iter().any(|x| x == p) {
|
||||||
|
patterns.push(p.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if patterns.is_empty() || patterns.len() > ANDROID_PATTERNS_MAX {
|
||||||
|
return Err(Error::Signing(format!("the grant names 1 to {ANDROID_PATTERNS_MAX} repositories")));
|
||||||
|
}
|
||||||
|
if !grant_subject_ok(o, c) {
|
||||||
|
return Err(Error::Signing(
|
||||||
|
"the certificates need an organisation (1-64 characters) and a two-letter country code".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
let old = self.signing.android.clone();
|
||||||
|
let grant = AndroidGrant {
|
||||||
|
repos: patterns,
|
||||||
|
o: o.into(),
|
||||||
|
c: c.into(),
|
||||||
|
granted: now,
|
||||||
|
last_used: old.as_ref().and_then(|g| g.last_used),
|
||||||
|
uses: old.as_ref().map_or(0, |g| g.uses),
|
||||||
|
made: old.map(|g| g.made).unwrap_or_default(),
|
||||||
|
};
|
||||||
|
self.security.standing_note(crate::security::Action::StandingGranted, &grant_words(&grant), now);
|
||||||
|
self.signing.android = Some(grant.clone());
|
||||||
|
Ok(grant)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Removes the Android grant (`standing-revoked`); the keys it made stay. False when there is none. The caller
|
||||||
|
/// saves.
|
||||||
|
pub fn android_grant_revoke(&mut self, now: i64) -> bool {
|
||||||
|
let Some(g) = self.signing.android.take() else { return false };
|
||||||
|
self.security.standing_note(crate::security::Action::StandingRevoked, &grant_words(&g), now);
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether `req` is signed by the Android grant: an `apk` from this PC's pipe with a run, in the key's scope, for
|
||||||
|
/// a repository the grant covers and pipeline `release`, by that repository's own app key (scoped to exactly it
|
||||||
|
/// and `release`, role release), while *Sign only with a card* is not ticked. A key's first signature fits.
|
||||||
|
pub fn android_grant_fits(&self, req: &Request, now: i64) -> bool {
|
||||||
|
let Some(g) = &self.signing.android else { return false };
|
||||||
|
let Ok((view, _)) = self.check(req, now) else { return false };
|
||||||
|
req.kind == SignKind::Apk
|
||||||
|
&& req.via == Via::Local
|
||||||
|
&& req.run.is_some()
|
||||||
|
&& !self.security.is_ticked(crate::security::Item::CardSigning)
|
||||||
|
&& view.kind == KeyKind::Android
|
||||||
|
&& view.role == Role::Release
|
||||||
|
&& req.context.pipeline == ANDROID_PIPELINE
|
||||||
|
&& grant_covers(g, &req.context.repo)
|
||||||
|
&& android_key_id(&req.context.repo).as_deref() == Some(req.key.as_str())
|
||||||
|
&& view.repos == [req.context.repo.clone()]
|
||||||
|
&& view.pipelines == [ANDROID_PIPELINE.to_string()]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Makes `repo`'s app key under the Android grant, when its first release asks (`custos-sign apk`): the grant
|
||||||
|
/// covers `repo`, `pipeline` is `release`, `via` is local, *Sign only with a card* is not ticked, and there is
|
||||||
|
/// no key under that id. RSA-4096, `CN=<Name>`, the grant's O and C, scoped to exactly `repo` and `release`.
|
||||||
|
/// Writes `standing-granted` with `Android grant made <id> for <repo> pipeline release`: a value every core since
|
||||||
|
/// 0.16.0 reads, so the phone and the web vault still open the vault (core 0.19.1). The caller saves. Slow: one
|
||||||
|
/// RSA-4096 key.
|
||||||
|
pub fn android_grant_make_key(&mut self, repo: &str, pipeline: &str, via: Via, now: i64) -> Result<String, Error> {
|
||||||
|
let no = |why: String| Err(Error::Signing(why));
|
||||||
|
let Some(g) = self.signing.android.clone() else { return no("there is no Android grant".into()) };
|
||||||
|
let (Some((_, name)), Some(id)) = (repo_parts(repo), android_key_id(repo)) else {
|
||||||
|
return no(format!("`{repo}` is not a repository (owner/name)"));
|
||||||
|
};
|
||||||
|
if via != Via::Local {
|
||||||
|
return no("the server runner never makes a key".into());
|
||||||
|
}
|
||||||
|
if pipeline != ANDROID_PIPELINE {
|
||||||
|
return no(format!("the Android grant makes keys for the pipeline `{ANDROID_PIPELINE}` only"));
|
||||||
|
}
|
||||||
|
if self.security.is_ticked(crate::security::Item::CardSigning) {
|
||||||
|
return no("Sign only with a card is ticked".into());
|
||||||
|
}
|
||||||
|
if !grant_covers(&g, repo) {
|
||||||
|
return no(format!("the Android grant does not cover `{repo}`"));
|
||||||
|
}
|
||||||
|
if self.signing.get(&id).is_some() {
|
||||||
|
return no(format!("there is a key `{id}` already"));
|
||||||
|
}
|
||||||
|
let mut cn = name.to_string();
|
||||||
|
if let Some(first) = cn.get_mut(0..1) {
|
||||||
|
first.make_ascii_uppercase();
|
||||||
|
}
|
||||||
|
let spec = AndroidKey {
|
||||||
|
id: id.clone(),
|
||||||
|
name: format!("{cn} Android"),
|
||||||
|
cn,
|
||||||
|
o: g.o.clone(),
|
||||||
|
c: g.c.clone(),
|
||||||
|
role: Role::Release,
|
||||||
|
pipelines: vec![ANDROID_PIPELINE.into()],
|
||||||
|
repos: vec![repo.into()],
|
||||||
|
};
|
||||||
|
self.signing_create_android(&spec, now)?;
|
||||||
|
if let Some(g) = self.signing.android.as_mut()
|
||||||
|
&& g.made.len() < ANDROID_MADE_MAX
|
||||||
|
{
|
||||||
|
g.made.push(id.clone());
|
||||||
|
}
|
||||||
|
let words = format!("Android grant made {id} for {repo} pipeline {ANDROID_PIPELINE}");
|
||||||
|
self.security.standing_note(crate::security::Action::StandingGranted, &words, now);
|
||||||
|
Ok(id)
|
||||||
|
}
|
||||||
|
|
||||||
/// Every request any key was named in, oldest first.
|
/// Every request any key was named in, oldest first.
|
||||||
pub fn signing_audit(&self) -> &[AuditEntry] {
|
pub fn signing_audit(&self) -> &[AuditEntry] {
|
||||||
&self.signing.audit
|
&self.signing.audit
|
||||||
|
|||||||
@@ -105,6 +105,13 @@ pub(crate) struct SignerJson {
|
|||||||
by: String,
|
by: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub(crate) struct Ticket {
|
||||||
|
request: String,
|
||||||
|
ticket: SecretString,
|
||||||
|
at: u64,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub(crate) struct Seen {
|
pub(crate) struct Seen {
|
||||||
request: String,
|
request: String,
|
||||||
@@ -153,6 +160,9 @@ pub(crate) struct TeamJson {
|
|||||||
signers: Vec<SignerJson>,
|
signers: Vec<SignerJson>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
seen: Vec<Seen>,
|
seen: Vec<Seen>,
|
||||||
|
/// The deployment tickets of requests signed here (core 0.18.1), kept 25 hours.
|
||||||
|
#[serde(default)]
|
||||||
|
tickets: Vec<Ticket>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
audit: Vec<TeamAuditEntry>,
|
audit: Vec<TeamAuditEntry>,
|
||||||
}
|
}
|
||||||
@@ -196,6 +206,7 @@ pub(crate) struct TeamState {
|
|||||||
targets: Vec<Target>,
|
targets: Vec<Target>,
|
||||||
signers: Vec<Signer>,
|
signers: Vec<Signer>,
|
||||||
seen: Vec<Seen>,
|
seen: Vec<Seen>,
|
||||||
|
tickets: Vec<Ticket>,
|
||||||
audit: Vec<TeamAuditEntry>,
|
audit: Vec<TeamAuditEntry>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,6 +302,7 @@ impl TeamState {
|
|||||||
targets,
|
targets,
|
||||||
signers,
|
signers,
|
||||||
seen: j.seen,
|
seen: j.seen,
|
||||||
|
tickets: j.tickets,
|
||||||
audit: j.audit,
|
audit: j.audit,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -340,6 +352,15 @@ impl TeamState {
|
|||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
seen: self.seen.clone(),
|
seen: self.seen.clone(),
|
||||||
|
tickets: self
|
||||||
|
.tickets
|
||||||
|
.iter()
|
||||||
|
.map(|t| Ticket {
|
||||||
|
request: t.request.clone(),
|
||||||
|
ticket: SecretString::new(t.ticket.expose().to_owned()),
|
||||||
|
at: t.at,
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
audit: self.audit.clone(),
|
audit: self.audit.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -604,6 +625,7 @@ impl Vault {
|
|||||||
targets: Vec::new(),
|
targets: Vec::new(),
|
||||||
signers: Vec::new(),
|
signers: Vec::new(),
|
||||||
seen: Vec::new(),
|
seen: Vec::new(),
|
||||||
|
tickets: Vec::new(),
|
||||||
audit: Vec::new(),
|
audit: Vec::new(),
|
||||||
};
|
};
|
||||||
state.log(now, TeamAction::TeamCreated, &me.id(), Some(name.into()));
|
state.log(now, TeamAction::TeamCreated, &me.id(), Some(name.into()));
|
||||||
@@ -978,6 +1000,12 @@ impl Vault {
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
let key = format!("target:{}:{}", target.id, req.deployment);
|
let key = format!("target:{}:{}", target.id, req.deployment);
|
||||||
|
// Only the Fabrica that opened this deployment's signing reply holds its ticket (docs/TEAM.md).
|
||||||
|
let ticket: Option<[u8; 32]> =
|
||||||
|
t.tickets.iter().find(|x| x.request == req.deployment).and_then(|x| unhex(x.ticket.expose()));
|
||||||
|
if !ticket.is_some_and(|k| req.mac_ok(&k)) {
|
||||||
|
return Err(Error::Team("the request does not carry this deployment's ticket".into()));
|
||||||
|
}
|
||||||
if t.is_seen(&key) {
|
if t.is_seen(&key) {
|
||||||
return Err(team_err(TeamError::Replayed));
|
return Err(team_err(TeamError::Replayed));
|
||||||
}
|
}
|
||||||
@@ -1108,6 +1136,9 @@ impl Vault {
|
|||||||
/// Records a refusal by `by`; the request is never signed here afterwards. The caller saves.
|
/// Records a refusal by `by`; the request is never signed here afterwards. The caller saves.
|
||||||
pub fn team_refuse(&mut self, text: &str, by: &str, reason: &str, now: i64) -> Result<(), Error> {
|
pub fn team_refuse(&mut self, text: &str, by: &str, reason: &str, now: i64) -> Result<(), Error> {
|
||||||
let req = SignRequest::parse(text).map_err(team_err)?;
|
let req = SignRequest::parse(text).map_err(team_err)?;
|
||||||
|
if self.team()?.is_seen(&req.hash_hex()) {
|
||||||
|
return Err(team_err(TeamError::Replayed));
|
||||||
|
}
|
||||||
let entry =
|
let entry =
|
||||||
self.team_audit_entry(&req, Outcome::Refused, by, Some(reason.chars().take(200).collect()), None, &[], now);
|
self.team_audit_entry(&req, Outcome::Refused, by, Some(reason.chars().take(200).collect()), None, &[], now);
|
||||||
self.signing.audit.push(entry);
|
self.signing.audit.push(entry);
|
||||||
@@ -1192,6 +1223,8 @@ impl Vault {
|
|||||||
let eval = evaluate(&t.policy, &roster, &req.env, &req.author, &approvers);
|
let eval = evaluate(&t.policy, &roster, &req.env, &req.author, &approvers);
|
||||||
let role = eval.clone().into_result()?;
|
let role = eval.clone().into_result()?;
|
||||||
let (key_id, envelope, payload, public) = self.team_envelope(&req, role, external, now_s)?;
|
let (key_id, envelope, payload, public) = self.team_envelope(&req, role, external, now_s)?;
|
||||||
|
let mut ticket = Zeroizing::new([0u8; 32]);
|
||||||
|
crypto::fill_random(ticket.as_mut());
|
||||||
let t = self.team.as_ref().expect("checked");
|
let t = self.team.as_ref().expect("checked");
|
||||||
let (policy_text, policy_sig) = (t.policy.canonical(), t.policy_sig);
|
let (policy_text, policy_sig) = (t.policy.canonical(), t.policy_sig);
|
||||||
let proof = ProofBody {
|
let proof = ProofBody {
|
||||||
@@ -1219,6 +1252,7 @@ impl Vault {
|
|||||||
key: ReplyKey { id: key_id.clone(), public },
|
key: ReplyKey { id: key_id.clone(), public },
|
||||||
signer: ReplySigner { member: me.clone(), name: me_member.name.clone() },
|
signer: ReplySigner { member: me.clone(), name: me_member.name.clone() },
|
||||||
proof,
|
proof,
|
||||||
|
ticket: Some(b64(ticket.as_ref())),
|
||||||
};
|
};
|
||||||
let outcome = if role == KeyRole::Release { Outcome::Approved } else { Outcome::Auto };
|
let outcome = if role == KeyRole::Release { Outcome::Approved } else { Outcome::Auto };
|
||||||
let mut entry = self.team_audit_entry(
|
let mut entry = self.team_audit_entry(
|
||||||
@@ -1233,7 +1267,10 @@ impl Vault {
|
|||||||
entry.key = key_id;
|
entry.key = key_id;
|
||||||
self.signing.audit.push(entry);
|
self.signing.audit.push(entry);
|
||||||
let hash = req.hash_hex();
|
let hash = req.hash_hex();
|
||||||
self.team.as_mut().expect("checked").mark_seen(hash, now_s);
|
let t = self.team.as_mut().expect("checked");
|
||||||
|
t.tickets.retain(|x| x.at + MAX_AHEAD_SECS > now_s);
|
||||||
|
t.tickets.push(Ticket { request: hash.clone(), ticket: SecretString::new(hex(ticket.as_ref())), at: now_s });
|
||||||
|
t.mark_seen(hash, now_s);
|
||||||
Ok(reply)
|
Ok(reply)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,266 @@
|
|||||||
|
//! The Android grant (core 0.19.0, docs/SIGNING.md "The Android grant"): one answer for every Domi app's release
|
||||||
|
//! APK. It signs a request for a repository's own app key (`<name>-android`, scoped to exactly that repository and
|
||||||
|
//! `release`) from this PC's pipe, its first signature included, and makes that key when the app's first release
|
||||||
|
//! asks. Everything else still needs a card.
|
||||||
|
|
||||||
|
use custos_vault::security::{Action, Auth, Item};
|
||||||
|
use custos_vault::signing::{
|
||||||
|
AndroidKey, Approval, Context, KeyKind, Outcome, Refusal, Request, Role, SignKind, Via, android_key_id,
|
||||||
|
};
|
||||||
|
use custos_vault::{KdfParams, SecretString, Vault};
|
||||||
|
|
||||||
|
const FAST: KdfParams = KdfParams { m_cost_kib: 64, t_cost: 1, p_cost: 1 };
|
||||||
|
const NOW: i64 = 1_793_750_000_000;
|
||||||
|
const COMMIT: &str = "6925d0cb08b9e0c5c3a4a7a2c37b7f2a9f7ed3b1";
|
||||||
|
|
||||||
|
fn s(v: &[&str]) -> Vec<String> {
|
||||||
|
v.iter().map(|x| x.to_string()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn vault() -> Vault {
|
||||||
|
let mut v = Vault::create(&SecretString::from("pw"), FAST).unwrap();
|
||||||
|
v.signing_create(Role::Release, &s(&["release"]), &s(&["mnovak/Culina"]), NOW).unwrap();
|
||||||
|
v
|
||||||
|
}
|
||||||
|
|
||||||
|
fn granted(repos: &[&str]) -> Vault {
|
||||||
|
let mut v = vault();
|
||||||
|
v.android_grant_set(&s(repos), "Marek Novak", "CZ", NOW).unwrap();
|
||||||
|
v
|
||||||
|
}
|
||||||
|
|
||||||
|
fn apk(key: &str, repo: &str, pipeline: &str, run: Option<&str>) -> Request {
|
||||||
|
Request {
|
||||||
|
key: key.into(),
|
||||||
|
kind: SignKind::Apk,
|
||||||
|
digest: vec![5; 64],
|
||||||
|
manifest: None,
|
||||||
|
approval: None,
|
||||||
|
run: run.map(Into::into),
|
||||||
|
context: Context {
|
||||||
|
repo: repo.into(),
|
||||||
|
commit: COMMIT.into(),
|
||||||
|
pipeline: pipeline.into(),
|
||||||
|
step: "sign-apk".into(),
|
||||||
|
trigger: "tag".into(),
|
||||||
|
file: "Culina-1.2.0.apk".into(),
|
||||||
|
size: 9_400_000,
|
||||||
|
sha256: "c4995c6e2e0c20fec7e8dcb05d70144da58f42d379c6705df66edb42abafb8a3".into(),
|
||||||
|
version: "1.2.0".into(),
|
||||||
|
},
|
||||||
|
via: Via::Local,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn culina(run: &str) -> Request {
|
||||||
|
apk("culina-android", "mnovak/Culina", "release", Some(run))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn notes(v: &Vault, action: Action) -> Vec<String> {
|
||||||
|
v.security_view(NOW + 1_000)
|
||||||
|
.audit
|
||||||
|
.into_iter()
|
||||||
|
.filter(|e| e.action == action)
|
||||||
|
.map(|e| e.detail.unwrap_or_default())
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn an_app_key_is_named_by_its_repository() {
|
||||||
|
assert_eq!(android_key_id("mnovak/Culina").as_deref(), Some("culina-android"));
|
||||||
|
assert_eq!(android_key_id("mnovak/domi-office").as_deref(), Some("domi-office-android"));
|
||||||
|
assert_eq!(android_key_id("mnovak/Domi.Office_2").as_deref(), Some("domi-office-2-android"));
|
||||||
|
for bad in ["Culina", "mnovak/", "/Culina", "mnovak/*", "a/b/c", "mnovak/Cu lina", "mnovak/Čulina", ""] {
|
||||||
|
assert_eq!(android_key_id(bad), None, "{bad}");
|
||||||
|
}
|
||||||
|
assert_eq!(android_key_id(&format!("mnovak/{}", "x".repeat(57))), None, "the id would be longer than 64");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_grant_makes_an_apps_key_and_signs_its_first_apk_without_a_card() {
|
||||||
|
let mut v = granted(&["mnovak/*"]);
|
||||||
|
assert!(!v.android_grant_fits(&culina("r-1"), NOW + 1), "no key yet");
|
||||||
|
|
||||||
|
let id = v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW + 1).unwrap();
|
||||||
|
assert_eq!(id, "culina-android");
|
||||||
|
let k = v.signing_keys().into_iter().find(|k| k.id == id).unwrap();
|
||||||
|
assert_eq!((k.kind, k.role, k.name.as_str()), (KeyKind::Android, Role::Release, "Culina Android"));
|
||||||
|
assert_eq!((k.pipelines.clone(), k.repos.clone()), (s(&["release"]), s(&["mnovak/Culina"])));
|
||||||
|
let cert = String::from_utf8_lossy(k.cert.as_ref().unwrap()).into_owned();
|
||||||
|
assert!(cert.contains("Culina") && cert.contains("Marek Novak"), "the certificate names the app and Mark");
|
||||||
|
|
||||||
|
// Its first signature: no card, recorded as `standing`, counted on the grant.
|
||||||
|
assert!(v.android_grant_fits(&culina("r-1"), NOW + 2));
|
||||||
|
assert!(v.standing_rule_for(&culina("r-1"), NOW + 2).is_none(), "the grant is not a per-key rule");
|
||||||
|
let signed = v.signing_sign(&culina("r-1"), Approval::Standing, NOW + 2);
|
||||||
|
assert!(signed.is_ok(), "{signed:?}");
|
||||||
|
assert_eq!(v.signing_audit().last().unwrap().outcome, Outcome::Standing);
|
||||||
|
assert_eq!(v.signing_audit().last().unwrap().context.file, "Culina-1.2.0.apk");
|
||||||
|
v.signing_sign(&culina("r-2"), Approval::Standing, NOW + 3).unwrap();
|
||||||
|
let g = v.android_grant().unwrap();
|
||||||
|
assert_eq!((g.uses, g.last_used, g.made.clone()), (2, Some(NOW + 3), s(&["culina-android"])));
|
||||||
|
|
||||||
|
// Granting, then the key it made: both `standing-granted`, a value cores since 0.16.0 read (core 0.19.1).
|
||||||
|
let granted_note = notes(&v, Action::StandingGranted);
|
||||||
|
assert_eq!(granted_note.len(), 2, "{granted_note:?}");
|
||||||
|
assert!(granted_note[0].contains("Android releases") && granted_note[0].contains("mnovak/*"), "{granted_note:?}");
|
||||||
|
assert_eq!(granted_note[1], "Android grant made culina-android for mnovak/Culina pipeline release");
|
||||||
|
// The public note call cannot write it.
|
||||||
|
assert!(v.security_note(Action::StandingGranted, "x", NOW).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_grant_never_makes_a_key_it_does_not_cover() {
|
||||||
|
let mut v = granted(&["mnovak/Culina", "mnovak/Liber"]);
|
||||||
|
for (repo, pipeline, via, why) in [
|
||||||
|
("mnovak/Postea", "release", Via::Local, "a repository no pattern matches"),
|
||||||
|
("someone/Culina", "release", Via::Local, "another owner"),
|
||||||
|
("mnovak/Culina", "ci", Via::Local, "another pipeline"),
|
||||||
|
("mnovak/Culina", "release", Via::Remote, "the server runner"),
|
||||||
|
("Culina", "release", Via::Local, "not owner/name"),
|
||||||
|
] {
|
||||||
|
assert!(v.android_grant_make_key(repo, pipeline, via, NOW + 1).is_err(), "{why}");
|
||||||
|
}
|
||||||
|
assert!(v.signing_keys().iter().all(|k| k.kind != KeyKind::Android), "nothing was made");
|
||||||
|
v.android_grant_make_key("mnovak/Liber", "release", Via::Local, NOW + 2).unwrap();
|
||||||
|
assert!(v.android_grant_make_key("mnovak/Liber", "release", Via::Local, NOW + 3).is_err(), "made once");
|
||||||
|
|
||||||
|
v.security_tick(Item::CardSigning, NOW + 4);
|
||||||
|
assert!(v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW + 5).is_err(), "paused");
|
||||||
|
v.security_untick(Item::CardSigning, Auth::Hello, NOW + 6);
|
||||||
|
assert!(v.android_grant_revoke(NOW + 7));
|
||||||
|
assert!(v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW + 8).is_err(), "no grant");
|
||||||
|
assert_eq!(v.android_grant().map(|g| g.made), None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn only_the_repositorys_own_app_key_in_its_own_scope_from_this_pc_with_a_run_fits() {
|
||||||
|
let mut v = granted(&["mnovak/*"]);
|
||||||
|
v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW).unwrap();
|
||||||
|
// A key of the right name with a wider scope, and one for the wrong repository, made by hand.
|
||||||
|
let wide = AndroidKey {
|
||||||
|
id: "liber-android".into(),
|
||||||
|
name: "Liber Android".into(),
|
||||||
|
cn: "Liber".into(),
|
||||||
|
o: "Marek Novak".into(),
|
||||||
|
c: "CZ".into(),
|
||||||
|
role: Role::Release,
|
||||||
|
pipelines: s(&["release"]),
|
||||||
|
repos: s(&["*"]),
|
||||||
|
};
|
||||||
|
v.signing_create_android(&wide, NOW).unwrap();
|
||||||
|
v.signing_create_android(
|
||||||
|
&AndroidKey { id: "other-android".into(), repos: s(&["mnovak/Rosea"]), ..wide.clone() },
|
||||||
|
NOW,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
v.signing_create_android(&AndroidKey { id: "domi-test-android".into(), role: Role::Test, ..wide.clone() }, NOW)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let mut remote = culina("r-1");
|
||||||
|
remote.via = Via::Remote;
|
||||||
|
let mut minisign = culina("r-1");
|
||||||
|
minisign.kind = SignKind::Minisign;
|
||||||
|
minisign.key = "domi-release".into();
|
||||||
|
minisign.digest = vec![7; 64];
|
||||||
|
for (req, why) in [
|
||||||
|
(remote, "the server runner"),
|
||||||
|
(apk("culina-android", "mnovak/Culina", "release", None), "no run"),
|
||||||
|
(apk("liber-android", "mnovak/Liber", "release", Some("r-1")), "a key with a wider scope"),
|
||||||
|
(apk("other-android", "mnovak/Rosea", "release", Some("r-1")), "not the repository's app key"),
|
||||||
|
(apk("domi-test-android", "mnovak/Liber", "release", Some("r-1")), "a test key"),
|
||||||
|
(minisign, "another kind"),
|
||||||
|
] {
|
||||||
|
assert!(!v.android_grant_fits(&req, NOW + 1), "{why}");
|
||||||
|
assert!(v.signing_sign(&req, Approval::Standing, NOW + 1).is_err(), "{why}: never signed without a card");
|
||||||
|
assert_ne!(v.signing_audit().last().unwrap().outcome, Outcome::Standing, "{why}");
|
||||||
|
}
|
||||||
|
assert_eq!(v.android_grant().unwrap().uses, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn an_explicit_list_covers_only_its_repositories_and_bad_patterns_are_refused() {
|
||||||
|
let mut v = granted(&["mnovak/Culina"]);
|
||||||
|
v.signing_create_android(
|
||||||
|
&AndroidKey {
|
||||||
|
id: "liber-android".into(),
|
||||||
|
name: "Liber Android".into(),
|
||||||
|
cn: "Liber".into(),
|
||||||
|
o: "Marek Novak".into(),
|
||||||
|
c: "CZ".into(),
|
||||||
|
role: Role::Release,
|
||||||
|
pipelines: s(&["release"]),
|
||||||
|
repos: s(&["mnovak/Liber"]),
|
||||||
|
},
|
||||||
|
NOW,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let liber = apk("liber-android", "mnovak/Liber", "release", Some("r-1"));
|
||||||
|
assert!(!v.android_grant_fits(&liber, NOW + 1), "not in the list");
|
||||||
|
// Editing the list keeps the counts and covers the new repository; a key made by hand in that shape is covered.
|
||||||
|
v.android_grant_set(&s(&["mnovak/Culina", "mnovak/Liber", "mnovak/Liber"]), "Marek Novak", "CZ", NOW + 2).unwrap();
|
||||||
|
assert_eq!(v.android_grant().unwrap().repos, s(&["mnovak/Culina", "mnovak/Liber"]));
|
||||||
|
assert!(v.android_grant_fits(&liber, NOW + 3));
|
||||||
|
|
||||||
|
for bad in [&[][..], &["mnovak"], &["*/*"], &["*"], &["mnovak/*/x"], &["mn ovak/*"], &["mnovak/Cu*"]] {
|
||||||
|
assert!(v.android_grant_set(&s(bad), "Marek Novak", "CZ", NOW + 4).is_err(), "{bad:?}");
|
||||||
|
}
|
||||||
|
let many: Vec<String> = (0..65).map(|i| format!("mnovak/app{i}")).collect();
|
||||||
|
assert!(v.android_grant_set(&many, "Marek Novak", "CZ", NOW + 4).is_err(), "at most 64");
|
||||||
|
assert!(v.android_grant_set(&s(&["mnovak/*"]), "Marek Novak", "Czech", NOW + 4).is_err(), "a two-letter country");
|
||||||
|
assert!(v.android_grant_set(&s(&["mnovak/*"]), "", "CZ", NOW + 4).is_err(), "an organisation");
|
||||||
|
assert_eq!(
|
||||||
|
v.android_grant().unwrap().repos,
|
||||||
|
s(&["mnovak/Culina", "mnovak/Liber"]),
|
||||||
|
"a refused edit changes nothing"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sign_only_with_a_card_pauses_the_grant_and_revoking_ends_it() {
|
||||||
|
let mut v = granted(&["mnovak/*"]);
|
||||||
|
v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW).unwrap();
|
||||||
|
v.security_tick(Item::CardSigning, NOW + 1);
|
||||||
|
assert!(!v.android_grant_fits(&culina("r-1"), NOW + 2));
|
||||||
|
assert!(matches!(v.signing_sign(&culina("r-1"), Approval::Standing, NOW + 2), Err(Refusal::NeedsApproval(_))));
|
||||||
|
assert!(v.android_grant_set(&s(&["mnovak/*"]), "Marek Novak", "CZ", NOW + 2).is_err(), "no grant while ticked");
|
||||||
|
assert!(v.android_grant().is_some(), "kept, paused");
|
||||||
|
v.security_untick(Item::CardSigning, Auth::Hello, NOW + 3);
|
||||||
|
assert!(v.android_grant_fits(&culina("r-1"), NOW + 4));
|
||||||
|
|
||||||
|
assert!(v.android_grant_revoke(NOW + 5));
|
||||||
|
assert!(!v.android_grant_revoke(NOW + 6), "once");
|
||||||
|
assert!(!v.android_grant_fits(&culina("r-2"), NOW + 7));
|
||||||
|
assert!(matches!(v.signing_sign(&culina("r-2"), Approval::Standing, NOW + 7), Err(Refusal::NeedsApproval(_))));
|
||||||
|
// Mark still signs it on a card, and the key stays.
|
||||||
|
assert!(v.signing_sign(&culina("r-2"), Approval::Mark, NOW + 8).is_ok());
|
||||||
|
let revoked = notes(&v, Action::StandingRevoked);
|
||||||
|
assert_eq!(revoked.len(), 1);
|
||||||
|
assert!(revoked[0].contains("Android releases"), "{revoked:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_standing_rule_for_the_same_request_is_used_first() {
|
||||||
|
let mut v = granted(&["mnovak/*"]);
|
||||||
|
v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW).unwrap();
|
||||||
|
v.signing_sign(&culina("r-1"), Approval::Mark, NOW + 1).unwrap();
|
||||||
|
v.standing_grant(&culina("r-2"), NOW + 2).unwrap();
|
||||||
|
v.signing_sign(&culina("r-2"), Approval::Standing, NOW + 2).unwrap();
|
||||||
|
assert_eq!(v.standing_rules()[0].uses, 1);
|
||||||
|
assert_eq!(v.android_grant().unwrap().uses, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_grant_and_its_counts_survive_a_reopen() {
|
||||||
|
let mut v = granted(&["mnovak/*", "domi/*"]);
|
||||||
|
v.android_grant_make_key("mnovak/Culina", "release", Via::Local, NOW).unwrap();
|
||||||
|
v.signing_sign(&culina("r-1"), Approval::Standing, NOW + 1).unwrap();
|
||||||
|
|
||||||
|
let mut back = Vault::open(&v.to_bytes().unwrap(), &SecretString::from("pw")).unwrap();
|
||||||
|
assert_eq!(back.android_grant(), v.android_grant());
|
||||||
|
assert!(back.signing_sign(&culina("r-2"), Approval::Standing, NOW + 2).is_ok());
|
||||||
|
assert_eq!(back.android_grant().unwrap().uses, 2);
|
||||||
|
assert!(back.android_grant_revoke(NOW + 3));
|
||||||
|
let again = Vault::open(&back.to_bytes().unwrap(), &SecretString::from("pw")).unwrap();
|
||||||
|
assert_eq!(again.android_grant(), None);
|
||||||
|
}
|
||||||
@@ -240,6 +240,8 @@ fn wrong_and_replayed_match_codes_are_refused() {
|
|||||||
assert!(matches!(t.vault.team_sign(&text, &[], &t.a, Some(&code), None, NOW), Err(TeamError::NotEligible(_))));
|
assert!(matches!(t.vault.team_sign(&text, &[], &t.a, Some(&code), None, NOW), Err(TeamError::NotEligible(_))));
|
||||||
// Petra with the right code signs.
|
// Petra with the right code signs.
|
||||||
let reply = t.vault.team_sign(&text, &[], &t.b, Some(&code), None, NOW).unwrap();
|
let reply = t.vault.team_sign(&text, &[], &t.b, Some(&code), None, NOW).unwrap();
|
||||||
|
// A refusal after the signature is refused too: nothing contradicts what was signed (core 0.18.1).
|
||||||
|
assert!(t.vault.team_refuse(&text, &t.a.id(), "late", NOW).unwrap_err().to_string().contains("replay"));
|
||||||
// The same request again (a replay): refused, by this vault, whoever asks.
|
// The same request again (a replay): refused, by this vault, whoever asks.
|
||||||
assert_eq!(t.vault.team_sign(&text, &[], &t.b, Some(&code), None, NOW).unwrap_err(), TeamError::Replayed);
|
assert_eq!(t.vault.team_sign(&text, &[], &t.b, Some(&code), None, NOW).unwrap_err(), TeamError::Replayed);
|
||||||
assert_eq!(t.vault.team_check_request(&text, NOW).unwrap_err(), TeamError::Replayed);
|
assert_eq!(t.vault.team_check_request(&text, NOW).unwrap_err(), TeamError::Replayed);
|
||||||
@@ -413,7 +415,10 @@ fn a_target_credential_is_released_once_for_a_signed_deployment_of_its_project_a
|
|||||||
assert!(!format!("{:?}", t.vault.team_targets().unwrap()).contains("apiVersion"));
|
assert!(!format!("{:?}", t.vault.team_targets().unwrap()).contains("apiVersion"));
|
||||||
let team_id = t.vault.team_view().unwrap().id;
|
let team_id = t.vault.team_view().unwrap().id;
|
||||||
let fabrica = custos_seal::Recipient::generate();
|
let fabrica = custos_seal::Recipient::generate();
|
||||||
let ask = |deployment: &str| {
|
let ticket_of = |r: &custos_team::reply::SignReply| -> [u8; 32] {
|
||||||
|
data_encoding::BASE64.decode(r.ticket.as_deref().unwrap().as_bytes()).unwrap().try_into().unwrap()
|
||||||
|
};
|
||||||
|
let ask = |deployment: &str, ticket: &[u8; 32]| {
|
||||||
TargetRequest {
|
TargetRequest {
|
||||||
team: team_id.clone(),
|
team: team_id.clone(),
|
||||||
id: custos_team::new_id(),
|
id: custos_team::new_id(),
|
||||||
@@ -421,18 +426,24 @@ fn a_target_credential_is_released_once_for_a_signed_deployment_of_its_project_a
|
|||||||
deployment: deployment.into(),
|
deployment: deployment.into(),
|
||||||
public: fabrica.public(),
|
public: fabrica.public(),
|
||||||
expires: NOW_S + 600,
|
expires: NOW_S + 600,
|
||||||
|
mac: [0; 32],
|
||||||
}
|
}
|
||||||
|
.sign_with(ticket)
|
||||||
.canonical()
|
.canonical()
|
||||||
};
|
};
|
||||||
// No signed deployment yet.
|
// No signed deployment yet.
|
||||||
let unsigned = "ab".repeat(32);
|
let unsigned = "ab".repeat(32);
|
||||||
assert!(t.vault.team_target_release(&ask(&unsigned), &t.b.id(), NOW).is_err());
|
assert!(t.vault.team_target_release(&ask(&unsigned, &[1; 32]), &t.b.id(), NOW).is_err());
|
||||||
// A staging deployment is not a production one.
|
// A staging deployment is not a production one.
|
||||||
let staging = request(&t.vault, "staging", "mnovak", Format::Minisign, &fabrica);
|
let staging = request(&t.vault, "staging", "mnovak", Format::Minisign, &fabrica);
|
||||||
let r = t.vault.team_sign(&staging, &[], &t.a, Some(&fabrica.match_code()), None, NOW).unwrap();
|
let r = t.vault.team_sign(&staging, &[], &t.a, Some(&fabrica.match_code()), None, NOW).unwrap();
|
||||||
assert!(t.vault.team_target_release(&ask(&r.request), &t.b.id(), NOW).is_err());
|
assert!(t.vault.team_target_release(&ask(&r.request, &ticket_of(&r)), &t.b.id(), NOW).is_err());
|
||||||
let prod = request(&t.vault, "production", "mnovak", Format::Minisign, &fabrica);
|
let prod = request(&t.vault, "production", "mnovak", Format::Minisign, &fabrica);
|
||||||
let r = t.vault.team_sign(&prod, &[], &t.b, Some(&fabrica.match_code()), None, NOW).unwrap();
|
let r = t.vault.team_sign(&prod, &[], &t.b, Some(&fabrica.match_code()), None, NOW).unwrap();
|
||||||
|
// Someone who knows the deployment's hash (the service, another connection) but not its ticket gets nothing.
|
||||||
|
let e = t.vault.team_target_release(&ask(&r.request, &[7; 32]), &t.b.id(), NOW).unwrap_err();
|
||||||
|
assert!(e.to_string().contains("ticket"), "{e}");
|
||||||
|
let ask = |deployment: &str| ask(deployment, &ticket_of(&r));
|
||||||
let (json, req) = t.vault.team_target_release(&ask(&r.request), &t.b.id(), NOW).unwrap();
|
let (json, req) = t.vault.team_target_release(&ask(&r.request), &t.b.id(), NOW).unwrap();
|
||||||
let released: TargetRelease = serde_json::from_str(&json).unwrap();
|
let released: TargetRelease = serde_json::from_str(&json).unwrap();
|
||||||
assert_eq!((released.secret.as_str(), released.env.as_str()), ("apiVersion: v1\nkind: Config\n", "production"));
|
assert_eq!((released.secret.as_str(), released.env.as_str()), ("apiVersion: v1\nkind: Config\n", "production"));
|
||||||
|
|||||||
+5
-2
@@ -149,7 +149,10 @@ of kind `android` and an audit entry of kind `apk` (docs/SIGNING.md); a vault th
|
|||||||
core before 0.14.0. Core 0.16.0 adds the `signing` audit outcome `standing` and the `security` actions
|
core before 0.14.0. Core 0.16.0 adds the `signing` audit outcome `standing` and the `security` actions
|
||||||
`standing-granted` and `standing-revoked` (docs/SIGNING.md, "Standing approvals"): a vault in which a standing
|
`standing-granted` and `standing-revoked` (docs/SIGNING.md, "Standing approvals"): a vault in which a standing
|
||||||
approval was ever granted does not open in a core before 0.16.0. The rules themselves (`signing.standing`) are a
|
approval was ever granted does not open in a core before 0.16.0. The rules themselves (`signing.standing`) are a
|
||||||
member older cores ignore and drop.
|
member older cores ignore and drop. Core 0.19.0 adds the member `signing.android` (the Android grant, docs/SIGNING.md "The Android
|
||||||
|
grant"), which older cores ignore and drop (the grant is lost, never widened). It adds no closed-list value:
|
||||||
|
a key the grant makes is `standing-granted` in the security audit (core 0.19.1), so a vault with the grant still
|
||||||
|
opens in every core since 0.16.0, as the phone app and the web vault may be.
|
||||||
|
|
||||||
### The provision audit (core 0.11.0)
|
### The provision audit (core 0.11.0)
|
||||||
|
|
||||||
@@ -213,7 +216,7 @@ an outcome; a code the server then refuses (its exit 10) is not seen by Custos,
|
|||||||
| `finished` | optional: when that window ended, by *Finish setup*, or `until` once its expiry was noticed |
|
| `finished` | optional: when that window ended, by *Finish setup*, or `until` once its expiry was noticed |
|
||||||
| `ticked` | the checklist items that are ticked: `totp-on-phone`, `hello-approvals`, `narrow-scope`, `rotate-setup`, `no-ssh`, `phone-approves`, and (core 0.13.0) `no-auto-connect`, `no-unattended`, `card-signing` |
|
| `ticked` | the checklist items that are ticked: `totp-on-phone`, `hello-approvals`, `narrow-scope`, `rotate-setup`, `no-ssh`, `phone-approves`, and (core 0.13.0) `no-auto-connect`, `no-unattended`, `card-signing` |
|
||||||
| `keptScope` | optional: the server scope prefixes *Narrow the server scope* replaced (`ask`, `offer`: at most 64 each, 1–200 characters, no control characters), kept for its undo |
|
| `keptScope` | optional: the server scope prefixes *Narrow the server scope* replaced (`ask`, `offer`: at most 64 each, 1–200 characters, no control characters), kept for its undo |
|
||||||
| `audit` | `{at, action, item?, auth?, detail?}`; `action` is `setup-started`, `setup-finished`, `setup-expired`, `ticked`, `unticked`, `ssh-connected`, `totp-moved`, or (core 0.13.0) `auto-connected`, `unattended-stored`, `setup-item-removed`, `unattended-signed`, `taken-over`, or (core 0.16.0) `standing-granted`, `standing-revoked`, or (core 0.17.0) `recovery-created`, `recovery-removed`, `recovered` (docs/FACTORS.md, "The recovery key"; their `detail` is the key's id); `item` a checklist item (with `ticked`, `unticked`); `auth` is `hello` or `password` (with `unticked`); `detail` (core 0.13.0, the four notes; core 0.16.0, the two standing actions) names what happened, never a value: 1–500 characters, no control characters |
|
| `audit` | `{at, action, item?, auth?, detail?}`; `action` is `setup-started`, `setup-finished`, `setup-expired`, `ticked`, `unticked`, `ssh-connected`, `totp-moved`, or (core 0.13.0) `auto-connected`, `unattended-stored`, `setup-item-removed`, `unattended-signed`, `taken-over`, or (core 0.16.0) `standing-granted`, `standing-revoked` (also for the Android grant and the keys it makes), or (core 0.17.0) `recovery-created`, `recovery-removed`, `recovered` (docs/FACTORS.md, "The recovery key"; their `detail` is the key's id); `item` a checklist item (with `ticked`, `unticked`); `auth` is `hello` or `password` (with `unticked`); `detail` (core 0.13.0, the four notes; core 0.16.0, the two standing actions) names what happened, never a value: 1–500 characters, no control characters |
|
||||||
|
|
||||||
The **level** is computed, never stored:
|
The **level** is computed, never stored:
|
||||||
|
|
||||||
|
|||||||
+60
-1
@@ -1,4 +1,4 @@
|
|||||||
# Signing keys (core 0.9.0; deploy approvals 0.12.0; Android APKs 0.14.0; standing approvals 0.16.0; teams 0.18.0)
|
# Signing keys (core 0.9.0; deploy approvals 0.12.0; Android APKs 0.14.0; standing approvals 0.16.0; teams 0.18.0; the Android grant 0.19.0)
|
||||||
|
|
||||||
Custos signs releases for Fabrica Domi · Artifex without a private key ever leaving the vault. A build asks for a
|
Custos signs releases for Fabrica Domi · Artifex without a private key ever leaving the vault. A build asks for a
|
||||||
signature over a **digest**; Custos checks who may ask, Mark approves with a match code, and the vault signs and
|
signature over a **digest**; Custos checks who may ask, Mark approves with a match code, and the vault signs and
|
||||||
@@ -249,6 +249,59 @@ Never covered by a rule, by construction: another repository, key, kind, pipelin
|
|||||||
key's scope; a request without a run; a key's first signature; a deploy to a target the rule was not granted for;
|
key's scope; a request without a run; a key's first signature; a deploy to a target the rule was not granted for;
|
||||||
a release signature the server runner asks for; creating a key.
|
a release signature the server runner asks for; creating a key.
|
||||||
|
|
||||||
|
## The Android grant (core 0.19.0)
|
||||||
|
|
||||||
|
A standing approval is one repository's one key, and never a key's first signature. Mark has a dozen Domi apps, each
|
||||||
|
with its own Android key (`<app>-android`), each new: that is a card to make the key's first signature and another to
|
||||||
|
store the rule, per app. **The Android grant** is one answer for all of them: "sign my apps' release APKs, and make
|
||||||
|
each app's key when its first release asks". One grant per vault, in `signing.android`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"android": { "repos": ["mnovak/*"], "o": "Marek Novak", "c": "CZ", "granted": 1794000000000,
|
||||||
|
"lastUsed": 1794100000000, "uses": 3, "made": ["culina-android"] }
|
||||||
|
```
|
||||||
|
|
||||||
|
- `repos`: 1 to 64 patterns, each `owner/name` or `owner/*` (every repository of that owner, never another
|
||||||
|
owner's); owner and name are 1 to 64 of `A-Z a-z 0-9 . _ -`.
|
||||||
|
- `o`, `c`: the certificate subject's organisation and country for the keys it makes.
|
||||||
|
- `uses`, `lastUsed`: as on a standing approval. `made`: the ids of the keys it made, oldest first (at most 256).
|
||||||
|
|
||||||
|
**An app's key** is named by its repository: `android_key_id("mnovak/Culina")` is `culina-android` (the name in
|
||||||
|
lower case, `.` and `_` as `-`). The grant only ever deals in that key, and only when its scope is exactly that
|
||||||
|
repository and the pipeline `release`, with the role `release`: a key with a wider scope (or `*`) is never the
|
||||||
|
grant's, and a key the grant did not make but that has this shape (`postea-android`) is covered too.
|
||||||
|
|
||||||
|
**A request fits the grant** (`android_grant_fits`) when all of these hold:
|
||||||
|
|
||||||
|
- `signing_check` passes (scope as always: the grant never widens a key's scope);
|
||||||
|
- the kind is `apk` and `via` is `local`: an APK the server runner asks for never fits;
|
||||||
|
- the request names a run;
|
||||||
|
- the pipeline is `release` and the repository matches one of the patterns;
|
||||||
|
- the key is that repository's app key, as above;
|
||||||
|
- `card-signing` (*Sign only with a card*) is not ticked.
|
||||||
|
|
||||||
|
A key's first signature fits too: that is the point of the grant. `signing_sign(req, Approval::Standing, now)` signs
|
||||||
|
a request that fits a standing approval or the grant (a standing approval first), records the outcome `standing`,
|
||||||
|
and counts the use on whichever fitted.
|
||||||
|
|
||||||
|
**Making a key** (`android_grant_make_key(repo, pipeline, via, now)`): the grant covers the repository, the
|
||||||
|
pipeline is `release`, `via` is `local`, `card-signing` is not ticked, and the vault has no key under that id. It
|
||||||
|
makes the RSA-4096 key with the certificate `CN=<Name>` (the repository's name, first letter upper case), `O` and `C`
|
||||||
|
from the grant, named `<Name> Android`, scoped to exactly that repository and `release`, adds the id to `made`, and
|
||||||
|
writes `standing-granted` to the security audit (`Android grant made <id> for <repo> pipeline release`). Core 0.19.0
|
||||||
|
wrote a new action, `android-key-made`, which older cores refuse; 0.19.1 keeps to the values every core since 0.16.0
|
||||||
|
reads, because the phone app and the web vault open the same vault. It is a key like any other: not exportable,
|
||||||
|
removed only as any key is.
|
||||||
|
|
||||||
|
**Granting** (`android_grant_set(repos, o, c, now)`) stores or replaces the grant (the counts and `made` stay) and
|
||||||
|
writes `standing-granted` with `Android releases: <patterns> pipeline release, keys made on first use`. It is
|
||||||
|
refused while `card-signing` is ticked. `android_grant_revoke` removes it (`standing-revoked`). Neither asks
|
||||||
|
anyone: the app calls them only from Mark's own click.
|
||||||
|
|
||||||
|
Never covered by the grant: another kind, the server runner, a pipeline other than `release`, a repository no pattern
|
||||||
|
matches, a key that is not the repository's app key, a request without a run, anything while *Sign only with a card*
|
||||||
|
is ticked.
|
||||||
|
|
||||||
## The audit log
|
## The audit log
|
||||||
|
|
||||||
`audit` is append-only: there is no function that edits or removes an entry. Every request a key is named in gets
|
`audit` is append-only: there is no function that edits or removes an entry. Every request a key is named in gets
|
||||||
@@ -302,6 +355,12 @@ Vault::standing_grant(&request, now) -> StandingRule //
|
|||||||
Vault::standing_rule_for(&request, now) -> Option<StandingRule>
|
Vault::standing_rule_for(&request, now) -> Option<StandingRule>
|
||||||
Vault::standing_rules() -> [StandingRule]
|
Vault::standing_rules() -> [StandingRule]
|
||||||
Vault::standing_revoke(id, now) -> bool
|
Vault::standing_revoke(id, now) -> bool
|
||||||
|
android_key_id(repo) -> Option<String> (core 0.19.0)
|
||||||
|
Vault::android_grant() -> Option<AndroidGrant>
|
||||||
|
Vault::android_grant_set(repos, o, c, now) -> Result<AndroidGrant, Error>
|
||||||
|
Vault::android_grant_revoke(now) -> bool
|
||||||
|
Vault::android_grant_fits(req, now) -> bool
|
||||||
|
Vault::android_grant_make_key(repo, pipeline, via, now) -> Result<String, Error>
|
||||||
```
|
```
|
||||||
|
|
||||||
No function returns a `secret`. The views and the audit entries print and serialise without one; there is a test.
|
No function returns a `secret`. The views and the audit entries print and serialise without one; there is a test.
|
||||||
|
|||||||
+24
-3
@@ -1,4 +1,4 @@
|
|||||||
# Team vaults, policies and team signing (core 0.18.0)
|
# Team vaults, policies and team signing (core 0.18.0; review fixes 0.18.1)
|
||||||
|
|
||||||
A **team vault** is a `.custos` file that a small team (1 to 32 people) shares: the team's release-signing keys,
|
A **team vault** is a `.custos` file that a small team (1 to 32 people) shares: the team's release-signing keys,
|
||||||
its target credentials, its external-signer credentials and its approval policy. Each member opens it with the
|
its target credentials, its external-signer credentials and its approval policy. Each member opens it with the
|
||||||
@@ -159,7 +159,9 @@ its own production releases (the `others` rule needs two members); when a second
|
|||||||
1. No rule for `env`: `UnknownEnv`.
|
1. No rule for `env`: `UnknownEnv`.
|
||||||
2. `approvals == 0`: `Allowed { key_role: Test }`.
|
2. `approvals == 0`: `Allowed { key_role: Test }`.
|
||||||
3. Eligible = roster members in `approvers` (or all); minus the author when `others` and the roster has ≥ 2 members.
|
3. Eligible = roster members in `approvers` (or all); minus the author when `others` and the roster has ≥ 2 members.
|
||||||
The author is the member whose id equals `author` or whose handles contain it.
|
The author is the member whose id equals `author` or whose handles contain it. Under `others` with 2+ members,
|
||||||
|
an author no member is (or an empty one) is `Unsatisfiable` (core 0.18.1): the rule cannot exclude someone it
|
||||||
|
cannot recognise, so it refuses instead of letting anyone approve.
|
||||||
4. Counted = distinct eligible members among `approvers` given. Members not on the roster, ineligible members and
|
4. Counted = distinct eligible members among `approvers` given. Members not on the roster, ineligible members and
|
||||||
duplicates are not counted (and listed in `ignored`).
|
duplicates are not counted (and listed in `ignored`).
|
||||||
5. Counted ≥ `approvals`: `Allowed { key_role: Release }`. Eligible < `approvals`: `Unsatisfiable` (no set of
|
5. Counted ≥ `approvals`: `Allowed { key_role: Release }`. Eligible < `approvals`: `Unsatisfiable` (no set of
|
||||||
@@ -274,13 +276,32 @@ layer's bytes, which are this payload.
|
|||||||
|
|
||||||
A target credential is handed to the Fabrica server for one deployment: `team_target_release(target id, request,
|
A target credential is handed to the Fabrica server for one deployment: `team_target_release(target id, request,
|
||||||
deployment, now)` returns the plaintext to seal, only when the target's `project` and `env` equal the deployment's,
|
deployment, now)` returns the plaintext to seal, only when the target's `project` and `env` equal the deployment's,
|
||||||
and records `target-released` with the deployment's request hash. One release per (target, deployment): a second
|
**and the request's `mac` was made with that deployment's ticket** (core 0.18.1), and records `target-released`
|
||||||
|
with the deployment's request hash.
|
||||||
|
|
||||||
|
**The ticket.** `team_sign` makes 32 random bytes per signed request, keeps them in the team body (`tickets`, 25
|
||||||
|
hours) and puts them in the reply (`"ticket"`, base64), which only the requester can open. A `target.request` ends
|
||||||
|
with `"mac":"<base64>"`: HMAC-SHA256(ticket, `"custos team target v1\0"` ‖ the canonical request up to and including
|
||||||
|
`"expires":N`, without the closing brace). Knowing a deployment's hash (the service stores every request text; a
|
||||||
|
proof names it) is not enough: without the ticket nobody else, not the service and not another connection, can ask
|
||||||
|
for its credentials or use up its one release. One release per (target, deployment): a second
|
||||||
call is `Replayed`. The app seals it to the server's one-time key (`team-target:<id>`); the service hands the box
|
call is `Replayed`. The app seals it to the server's one-time key (`team-target:<id>`); the service hands the box
|
||||||
out once, to the caller that asked (Custos `docs/27_team_vault.md`).
|
out once, to the caller that asked (Custos `docs/27_team_vault.md`).
|
||||||
|
|
||||||
`kind`: `ssh-key` (an OpenSSH private key), `winrm` (user and password), `openssh` (user and password),
|
`kind`: `ssh-key` (an OpenSSH private key), `winrm` (user and password), `openssh` (user and password),
|
||||||
`registry` (a Docker registry token), `kubeconfig` (the kubeconfig text). `secret` ≤ 64 KiB.
|
`registry` (a Docker registry token), `kubeconfig` (the kubeconfig text). `secret` ≤ 64 KiB.
|
||||||
|
|
||||||
|
## Limits (known, not fixed in 0.18.x)
|
||||||
|
|
||||||
|
- **Every member holds the team's secrets in their Custos**: the team identity, the release keys and the credentials
|
||||||
|
are in the body every member decrypts. Custos never hands them out, but a member running a modified build of the
|
||||||
|
public core can copy them before they are removed, and then sign directly, write proofs, or build a fork at a higher
|
||||||
|
epoch for the remaining members, which `member_note_team` would accept as current. Removing a member you no longer
|
||||||
|
trust means a new team (new identity, new keys), not only a new epoch.
|
||||||
|
- **Any member can change the policy.** `team_set_rule` is one member's action (audited as `policy-set`, signed by the
|
||||||
|
identity). A member who loosens production and then signs their own release passes `verify_proof`. Policy changes
|
||||||
|
that need the current policy's approvals are future work; until then, review the team audit.
|
||||||
|
|
||||||
## Crates
|
## Crates
|
||||||
|
|
||||||
`custos-team` (pure): member keys, wrapping, policy, request, statements, proof, envelopes, on `ed25519-dalek`,
|
`custos-team` (pure): member keys, wrapping, policy, request, statements, proof, envelopes, on `ed25519-dalek`,
|
||||||
|
|||||||
Reference in New Issue
Block a user