From e1d0071426929c3c453c7dedae0c30cd97028992 Mon Sep 17 00:00:00 2001 From: Sean Melissari Date: Fri, 19 Jun 2020 14:48:39 -0400 Subject: [PATCH 1/7] initial commit --- Dockerfile | 34 +++++++++ Jenkinsfile | 2 + LICENSE | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 14 +++- download.yaml | 3 + renovate.json | 22 ++++++ 6 files changed, 275 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 Jenkinsfile create mode 100644 LICENSE create mode 100644 download.yaml create mode 100644 renovate.json diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3936190 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +ARG BASE_REGISTRY=nexus-docker-secure.levelup-dev.io +ARG BASE_IMAGE=ubi8 +ARG BASE_TAG=8.2 + +FROM goharbor/notary-signer-photon:v2.0.0 as base + +FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} + +LABEL org.opencontainers.image.title="notary-signer" \ + org.opencontainers.image.description="Harbor is an open source cloud native registry that stores, signs, and scans content." \ + org.opencontainers.image.licenses="Apache-2.0" \ + org.opencontainers.image.url="https://goharbor.io" \ + org.opencontainers.image.version="v2.0.0" \ + maintainer="cht@dsop.io" + +ENV SERVICE_NAME=notary_signer + +RUN groupadd -g 1000 notary && \ + useradd -r -u 1000 -m -s /sbin/nologin -g notary notary && \ + dnf upgrade -y && \ + dnf clean all && \ + rm -rf /var/cache/dnf + +COPY --from=base /bin/migrate /bin/migrate +COPY --from=base /bin/migrate-patch /bin/migrate-patch +COPY --from=base /bin/notary-signer /bin/notary-signer +COPY --from=base /migrations /migrations + +USER notary + +HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ + CMD curl -k -sS https://127.0.0.1:7899 || exit 1 + +CMD migrate-patch -database=${DB_URL} && /migrations/migrate.sh && /bin/notary-signer -config=/etc/notary/signer-config.postgres.json -logf=logfmt diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..cf56100 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,2 @@ +@Library('DCCSCR@master') _ +dccscrPipeline(version: "v2.0.0") diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4b9cffe --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright Project Harbor Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index f30f6a7..a94cfcb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ -# notary-signer-photon +# Harbor +Harbor is an open source trusted cloud native registry project that stores, signs, and scans content. Harbor extends the open source Docker Distribution by adding the functionalities usually required by users such as security, identity and management. Having a registry closer to the build and run environment can improve the image transfer efficiency. Harbor supports replication of images between registries, and also offers advanced security features such as user management, access control and activity auditing. + +Harbor is hosted by the [Cloud Native Computing Foundation](https://cncf.io) (CNCF). If you are an organization that wants to help shape the evolution of cloud native technologies, consider joining the CNCF. For details about who's involved and how Harbor plays a role, read the CNCF +[announcement](https://www.cncf.io/blog/2018/07/31/cncf-to-host-harbor-in-the-sandbox/). + +## Documentation + +To learn more about Harbor [go to the complete documentation](https://goharbor.io/docs/latest/). + +## Deployment + +Refer to the official Helm [chart](https://github.com/goharbor/harbor-helm) for deployment instructions. diff --git a/download.yaml b/download.yaml new file mode 100644 index 0000000..fdaf270 --- /dev/null +++ b/download.yaml @@ -0,0 +1,3 @@ +resources: + - url: "docker://docker.io/goharbor/notary-signer-photon@sha256:d2c7995fb3a7d15433e17a58ce996d80bcfa9541282c07bc0d61ccaf1b20fa7f" + tag: "goharbor/notary-signer-photon:v2.0.0" diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..215a523 --- /dev/null +++ b/renovate.json @@ -0,0 +1,22 @@ +{ + "assignees": ["@sean.melissari"], + "baseBranches": ["development"], + "regexManagers": [ + { + "fileMatch": ["^Dockerfile$"], + "matchStrings": [ + "version=\"(?.*?)\"" + ], + "depNameTemplate": "goharbor/notary-signer-photon", + "datasourceTemplate": "docker" + }, + { + "fileMatch": ["^Jenkinsfile$"], + "matchStrings": [ + "version:\\s+\"(?.*?)\"" + ], + "depNameTemplate": "goharbor/notary-signer-photon", + "datasourceTemplate": "docker" + } + ] +} -- GitLab From 9a2ebc8254469a23e9840ab6ae78421331a59d60 Mon Sep 17 00:00:00 2001 From: renovate Date: Tue, 30 Jun 2020 17:59:56 +0000 Subject: [PATCH 2/7] Update goharbor/notary-signer-photon Docker tag to v2.0.1 --- Dockerfile | 4 ++-- Jenkinsfile | 2 +- download.yaml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3936190..c61d5c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ ARG BASE_REGISTRY=nexus-docker-secure.levelup-dev.io ARG BASE_IMAGE=ubi8 ARG BASE_TAG=8.2 -FROM goharbor/notary-signer-photon:v2.0.0 as base +FROM goharbor/notary-signer-photon:v2.0.1 as base FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} @@ -10,7 +10,7 @@ LABEL org.opencontainers.image.title="notary-signer" \ org.opencontainers.image.description="Harbor is an open source cloud native registry that stores, signs, and scans content." \ org.opencontainers.image.licenses="Apache-2.0" \ org.opencontainers.image.url="https://goharbor.io" \ - org.opencontainers.image.version="v2.0.0" \ + org.opencontainers.image.version="v2.0.1" \ maintainer="cht@dsop.io" ENV SERVICE_NAME=notary_signer diff --git a/Jenkinsfile b/Jenkinsfile index cf56100..dd8b15b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,2 +1,2 @@ @Library('DCCSCR@master') _ -dccscrPipeline(version: "v2.0.0") +dccscrPipeline(version: "v2.0.1") diff --git a/download.yaml b/download.yaml index fdaf270..64e53c3 100644 --- a/download.yaml +++ b/download.yaml @@ -1,3 +1,3 @@ resources: - - url: "docker://docker.io/goharbor/notary-signer-photon@sha256:d2c7995fb3a7d15433e17a58ce996d80bcfa9541282c07bc0d61ccaf1b20fa7f" - tag: "goharbor/notary-signer-photon:v2.0.0" + - url: "docker://docker.io/goharbor/notary-signer-photon@sha256:2d6b4ae2448f0e182a7f6bcac7b80da0ae06162e942e74a53e458530995aedf3" + tag: "goharbor/notary-signer-photon:v2.0.1" -- GitLab From 2279c2471d3221f1b6fbc5f1aee857d791d33aa4 Mon Sep 17 00:00:00 2001 From: renovate Date: Fri, 3 Jul 2020 00:00:45 +0000 Subject: [PATCH 3/7] Update goharbor/notary-signer-photon:v2.0.1 Docker digest to 172c160 --- download.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/download.yaml b/download.yaml index 64e53c3..03bd38e 100644 --- a/download.yaml +++ b/download.yaml @@ -1,3 +1,3 @@ resources: - - url: "docker://docker.io/goharbor/notary-signer-photon@sha256:2d6b4ae2448f0e182a7f6bcac7b80da0ae06162e942e74a53e458530995aedf3" + - url: "docker://docker.io/goharbor/notary-signer-photon@sha256:172c1607fd36d9e53d5929683910b6d3807532cafeeeea84aba3e6a0c3dd3d47" tag: "goharbor/notary-signer-photon:v2.0.1" -- GitLab From 5cf7427eb3cc9ea5884738496f5fe03646a0771e Mon Sep 17 00:00:00 2001 From: "sean.melissari" Date: Thu, 16 Jul 2020 15:41:43 +0000 Subject: [PATCH 4/7] update helm chart link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a94cfcb..6d45ad2 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,4 @@ To learn more about Harbor [go to the complete documentation](https://goharbor.i ## Deployment -Refer to the official Helm [chart](https://github.com/goharbor/harbor-helm) for deployment instructions. +Refer to the Helm [chart](https://repo1.dsop.io/dsop/charts/-/tree/master/harbor/harbor) for deployment instructions. -- GitLab From 2245672f1b4d2933abe7363ad1083ededad50bc4 Mon Sep 17 00:00:00 2001 From: Sean Melissari Date: Mon, 27 Jul 2020 16:23:08 -0400 Subject: [PATCH 5/7] vendor migration scripts --- Dockerfile | 2 +- Kptfile | 13 ++++++ scripts/Kptfile | 20 +++++++++ scripts/README.md | 8 ++++ scripts/migrate.sh | 41 +++++++++++++++++++ scripts/rethink_migrate.sh | 38 +++++++++++++++++ scripts/server/mysql/0001_initial.up.sql | 24 +++++++++++ scripts/server/mysql/0002_role_on_keys.up.sql | 3 ++ .../mysql/0003_add_sha256_tuf_files.up.sql | 5 +++ .../mysql/0004_drop_timestamp_key.up.sql | 1 + scripts/server/mysql/0005_changefeed.up.sql | 36 ++++++++++++++++ scripts/server/postgresql/0001_initial.up.sql | 14 +++++++ .../server/postgresql/0002_changefeed.up.sql | 34 +++++++++++++++ scripts/signer/mysql/0001_initial.up.sql | 16 ++++++++ .../signer/mysql/0002_gun_role_on_keys.up.sql | 1 + scripts/signer/postgresql/0001_initial.up.sql | 18 ++++++++ 16 files changed, 273 insertions(+), 1 deletion(-) create mode 100644 Kptfile create mode 100644 scripts/Kptfile create mode 100644 scripts/README.md create mode 100755 scripts/migrate.sh create mode 100755 scripts/rethink_migrate.sh create mode 100644 scripts/server/mysql/0001_initial.up.sql create mode 100644 scripts/server/mysql/0002_role_on_keys.up.sql create mode 100644 scripts/server/mysql/0003_add_sha256_tuf_files.up.sql create mode 100644 scripts/server/mysql/0004_drop_timestamp_key.up.sql create mode 100644 scripts/server/mysql/0005_changefeed.up.sql create mode 100644 scripts/server/postgresql/0001_initial.up.sql create mode 100644 scripts/server/postgresql/0002_changefeed.up.sql create mode 100644 scripts/signer/mysql/0001_initial.up.sql create mode 100644 scripts/signer/mysql/0002_gun_role_on_keys.up.sql create mode 100644 scripts/signer/postgresql/0001_initial.up.sql diff --git a/Dockerfile b/Dockerfile index c61d5c6..4bffff1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ RUN groupadd -g 1000 notary && \ COPY --from=base /bin/migrate /bin/migrate COPY --from=base /bin/migrate-patch /bin/migrate-patch COPY --from=base /bin/notary-signer /bin/notary-signer -COPY --from=base /migrations /migrations +COPY scripts /migrations USER notary diff --git a/Kptfile b/Kptfile new file mode 100644 index 0000000..1627636 --- /dev/null +++ b/Kptfile @@ -0,0 +1,13 @@ +apiVersion: kpt.dev/v1alpha1 +kind: Kptfile +metadata: + name: notary-signer +packageMetadata: + shortDescription: sample description +dependencies: + - name: scripts + git: + repo: https://github.com/theupdateframework/notary + directory: /migrations + ref: v0.6.1 + updateStrategy: fast-forward diff --git a/scripts/Kptfile b/scripts/Kptfile new file mode 100644 index 0000000..a1380c3 --- /dev/null +++ b/scripts/Kptfile @@ -0,0 +1,20 @@ +apiVersion: kpt.dev/v1alpha1 +kind: Kptfile +metadata: + name: notary-signer +upstream: + type: git + git: + commit: d6e1431feb32348e0650bf7551ac5cffd01d857b + repo: https://github.com/theupdateframework/notary + directory: /migrations + ref: v0.6.1 +packageMetadata: + shortDescription: sample description +dependencies: + - name: scripts + git: + repo: https://github.com/theupdateframework/notary + directory: /migrations + ref: v0.6.1 + updateStrategy: fast-forward diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..66f87fb --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,8 @@ +# Database Migrations + +This directory contains database migrations for the server and signer. They +are being managed using [this tool](https://github.com/mattes/migrate). +Within each of the server and signer directories are directories for different +database backends. Notary server and signer use GORM and are therefore +capable of running on a number of different databases, however migrations +may contain syntax specific to one backend. diff --git a/scripts/migrate.sh b/scripts/migrate.sh new file mode 100755 index 0000000..9fd988d --- /dev/null +++ b/scripts/migrate.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env sh + +# When run in the docker containers, the working directory +# is the root of the repo. + +iter=0 + +case $SERVICE_NAME in + notary_server) + MIGRATIONS_PATH=${MIGRATIONS_PATH:-migrations/server/mysql} + DB_URL=${DB_URL:-mysql://server@tcp(mysql:3306)/notaryserver} + # have to poll for DB to come up + until migrate -path=$MIGRATIONS_PATH -database="${DB_URL}" up + do + iter=$(( iter+1 )) + if [[ $iter -gt 30 ]]; then + echo "notaryserver database failed to come up within 30 seconds" + exit 1; + fi + echo "waiting for $DB_URL to come up." + sleep 1 + done + echo "notaryserver database migrated to latest version" + ;; + notary_signer) + MIGRATIONS_PATH=${MIGRATIONS_PATH:-migrations/signer/mysql} + DB_URL=${DB_URL:-mysql://signer@tcp(mysql:3306)/notarysigner} + # have to poll for DB to come up + until migrate -path=$MIGRATIONS_PATH -database="${DB_URL}" up + do + iter=$(( iter+1 )) + if [[ $iter -gt 30 ]]; then + echo "notarysigner database failed to come up within 30 seconds" + exit 1; + fi + echo "waiting for $DB_URL to come up." + sleep 1 + done + echo "notarysigner database migrated to latest version" + ;; +esac diff --git a/scripts/rethink_migrate.sh b/scripts/rethink_migrate.sh new file mode 100755 index 0000000..2a7b779 --- /dev/null +++ b/scripts/rethink_migrate.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# When run in the docker containers, the working directory +# is the root of the repo. + +iter=0 + +# have to poll for DB to come up +echo "trying to contact RethinkDB for 30 seconds before failing" +case $SERVICE_NAME in + notary_server) + # have to poll for DB to come up + until notary-server -config=fixtures/server-config.rethink.json -bootstrap + do + iter=$(( iter+1 )) + if [[ $iter -gt 30 ]]; then + echo "RethinkDB failed to come up within 30 seconds" + exit 1; + fi + echo "waiting for RethinkDB to come up." + sleep 1 + done + ;; + notary_signer) + # have to poll for DB to come up + until notary-signer -config=fixtures/signer-config.rethink.json -bootstrap + do + iter=$(( iter+1 )) + if [[ $iter -gt 30 ]]; then + echo "RethinkDB failed to come up within 30 seconds" + exit 1; + fi + echo "waiting for RethinkDB to come up." + sleep 1 + done + ;; +esac +echo "successfully reached and updated RethinkDB" diff --git a/scripts/server/mysql/0001_initial.up.sql b/scripts/server/mysql/0001_initial.up.sql new file mode 100644 index 0000000..e864b26 --- /dev/null +++ b/scripts/server/mysql/0001_initial.up.sql @@ -0,0 +1,24 @@ +CREATE TABLE `timestamp_keys` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + `gun` varchar(255) NOT NULL, + `cipher` varchar(50) NOT NULL, + `public` blob NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `gun` (`gun`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `tuf_files` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + `gun` varchar(255) NOT NULL, + `role` varchar(255) NOT NULL, + `version` int(11) NOT NULL, + `data` longblob NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `gun` (`gun`,`role`,`version`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/scripts/server/mysql/0002_role_on_keys.up.sql b/scripts/server/mysql/0002_role_on_keys.up.sql new file mode 100644 index 0000000..86f26c6 --- /dev/null +++ b/scripts/server/mysql/0002_role_on_keys.up.sql @@ -0,0 +1,3 @@ +ALTER TABLE `timestamp_keys` ADD COLUMN `role` VARCHAR(255) NOT NULL, DROP KEY `gun`, ADD UNIQUE KEY `gun_role` (`gun`, `role`); + +UPDATE `timestamp_keys` SET `role`="timestamp"; diff --git a/scripts/server/mysql/0003_add_sha256_tuf_files.up.sql b/scripts/server/mysql/0003_add_sha256_tuf_files.up.sql new file mode 100644 index 0000000..95a970b --- /dev/null +++ b/scripts/server/mysql/0003_add_sha256_tuf_files.up.sql @@ -0,0 +1,5 @@ +ALTER TABLE `tuf_files` ADD COLUMN `sha256` CHAR(64) DEFAULT NULL, ADD INDEX `sha256` (`sha256`); + +-- SHA2 function takes the column name or a string as the first parameter, and the +-- hash size as the second argument. It returns a hex string. +UPDATE `tuf_files` SET `sha256` = SHA2(`data`, 256); diff --git a/scripts/server/mysql/0004_drop_timestamp_key.up.sql b/scripts/server/mysql/0004_drop_timestamp_key.up.sql new file mode 100644 index 0000000..7868861 --- /dev/null +++ b/scripts/server/mysql/0004_drop_timestamp_key.up.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS `timestamp_keys`; \ No newline at end of file diff --git a/scripts/server/mysql/0005_changefeed.up.sql b/scripts/server/mysql/0005_changefeed.up.sql new file mode 100644 index 0000000..a652c46 --- /dev/null +++ b/scripts/server/mysql/0005_changefeed.up.sql @@ -0,0 +1,36 @@ +CREATE TABLE `change_category` ( + `category` VARCHAR(20) NOT NULL, + PRIMARY KEY (`category`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO `change_category` VALUES ("update"), ("deletion"); + +CREATE TABLE `changefeed` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `created_at` timestamp DEFAULT CURRENT_TIMESTAMP, + `gun` varchar(255) NOT NULL, + `version` int(11) NOT NULL, + `sha256` CHAR(64) DEFAULT NULL, + `category` VARCHAR(20) NOT NULL DEFAULT "update", + PRIMARY KEY (`id`), + FOREIGN KEY (`category`) REFERENCES `change_category` (`category`), + INDEX `idx_changefeed_gun` (`gun`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO `changefeed` ( + `created_at`, + `gun`, + `version`, + `sha256` + ) (SELECT + `created_at`, + `gun`, + `version`, + `sha256` + FROM + `tuf_files` + WHERE + `role` = "timestamp" + ORDER BY + `created_at` ASC +); diff --git a/scripts/server/postgresql/0001_initial.up.sql b/scripts/server/postgresql/0001_initial.up.sql new file mode 100644 index 0000000..218765a --- /dev/null +++ b/scripts/server/postgresql/0001_initial.up.sql @@ -0,0 +1,14 @@ +CREATE TABLE "tuf_files" ( + "id" serial PRIMARY KEY, + "created_at" timestamp NULL DEFAULT NULL, + "updated_at" timestamp NULL DEFAULT NULL, + "deleted_at" timestamp NULL DEFAULT NULL, + "gun" varchar(255) NOT NULL, + "role" varchar(255) NOT NULL, + "version" integer NOT NULL, + "data" bytea NOT NULL, + "sha256" char(64) DEFAULT NULL, + UNIQUE ("gun","role","version") +); + +CREATE INDEX tuf_files_sha256_idx ON tuf_files(sha256); diff --git a/scripts/server/postgresql/0002_changefeed.up.sql b/scripts/server/postgresql/0002_changefeed.up.sql new file mode 100644 index 0000000..7555b2e --- /dev/null +++ b/scripts/server/postgresql/0002_changefeed.up.sql @@ -0,0 +1,34 @@ +CREATE TABLE "change_category" ( + "category" VARCHAR(20) PRIMARY KEY +); + +INSERT INTO "change_category" VALUES ('update'), ('deletion'); + +CREATE TABLE "changefeed" ( + "id" serial PRIMARY KEY, + "created_at" timestamp DEFAULT CURRENT_TIMESTAMP, + "gun" varchar(255) NOT NULL, + "version" integer NOT NULL, + "sha256" CHAR(64) DEFAULT NULL, + "category" VARCHAR(20) NOT NULL DEFAULT 'update' REFERENCES "change_category" +); + +CREATE INDEX "idx_changefeed_gun" ON "changefeed" ("gun"); + +INSERT INTO "changefeed" ( + "created_at", + "gun", + "version", + "sha256" + ) (SELECT + "created_at", + "gun", + "version", + "sha256" + FROM + "tuf_files" + WHERE + "role" = 'timestamp' + ORDER BY + "created_at" ASC +); diff --git a/scripts/signer/mysql/0001_initial.up.sql b/scripts/signer/mysql/0001_initial.up.sql new file mode 100644 index 0000000..4cec140 --- /dev/null +++ b/scripts/signer/mysql/0001_initial.up.sql @@ -0,0 +1,16 @@ +CREATE TABLE `private_keys` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + `key_id` varchar(255) NOT NULL, + `encryption_alg` varchar(255) NOT NULL, + `keywrap_alg` varchar(255) NOT NULL, + `algorithm` varchar(50) NOT NULL, + `passphrase_alias` varchar(50) NOT NULL, + `public` blob NOT NULL, + `private` blob NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `key_id` (`key_id`), + UNIQUE KEY `key_id_2` (`key_id`,`algorithm`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/scripts/signer/mysql/0002_gun_role_on_keys.up.sql b/scripts/signer/mysql/0002_gun_role_on_keys.up.sql new file mode 100644 index 0000000..d0563e7 --- /dev/null +++ b/scripts/signer/mysql/0002_gun_role_on_keys.up.sql @@ -0,0 +1 @@ +ALTER TABLE `private_keys` ADD COLUMN `gun` VARCHAR(255) NOT NULL, ADD COLUMN `role` VARCHAR(255) NOT NULL, ADD COLUMN `last_used` DATETIME NULL DEFAULT NULL; \ No newline at end of file diff --git a/scripts/signer/postgresql/0001_initial.up.sql b/scripts/signer/postgresql/0001_initial.up.sql new file mode 100644 index 0000000..d7cf4ea --- /dev/null +++ b/scripts/signer/postgresql/0001_initial.up.sql @@ -0,0 +1,18 @@ +CREATE TABLE "private_keys" ( + "id" serial PRIMARY KEY, + "created_at" timestamp NULL DEFAULT NULL, + "updated_at" timestamp NULL DEFAULT NULL, + "deleted_at" timestamp NULL DEFAULT NULL, + "key_id" varchar(255) NOT NULL, + "encryption_alg" varchar(255) NOT NULL, + "keywrap_alg" varchar(255) NOT NULL, + "algorithm" varchar(50) NOT NULL, + "passphrase_alias" varchar(50) NOT NULL, + "public" bytea NOT NULL, + "private" bytea NOT NULL, + "gun" varchar(255) NOT NULL, + "role" varchar(255) NOT NULL, + "last_used" timestamp NULL DEFAULT NULL, + CONSTRAINT "key_id" UNIQUE ("key_id"), + CONSTRAINT "key_id_2" UNIQUE ("key_id","algorithm") +); -- GitLab From 539458883f5ffe3d724f09663281b74acb9541e8 Mon Sep 17 00:00:00 2001 From: renovate Date: Wed, 5 Aug 2020 00:01:25 +0000 Subject: [PATCH 6/7] Update goharbor/notary-signer-photon Docker tag to v2.0.2 --- Dockerfile | 4 ++-- Jenkinsfile | 2 +- download.yaml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4bffff1..569d3ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ ARG BASE_REGISTRY=nexus-docker-secure.levelup-dev.io ARG BASE_IMAGE=ubi8 ARG BASE_TAG=8.2 -FROM goharbor/notary-signer-photon:v2.0.1 as base +FROM goharbor/notary-signer-photon:v2.0.2 as base FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} @@ -10,7 +10,7 @@ LABEL org.opencontainers.image.title="notary-signer" \ org.opencontainers.image.description="Harbor is an open source cloud native registry that stores, signs, and scans content." \ org.opencontainers.image.licenses="Apache-2.0" \ org.opencontainers.image.url="https://goharbor.io" \ - org.opencontainers.image.version="v2.0.1" \ + org.opencontainers.image.version="v2.0.2" \ maintainer="cht@dsop.io" ENV SERVICE_NAME=notary_signer diff --git a/Jenkinsfile b/Jenkinsfile index dd8b15b..b5b6a4f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,2 +1,2 @@ @Library('DCCSCR@master') _ -dccscrPipeline(version: "v2.0.1") +dccscrPipeline(version: "v2.0.2") diff --git a/download.yaml b/download.yaml index 03bd38e..483e5c7 100644 --- a/download.yaml +++ b/download.yaml @@ -1,3 +1,3 @@ resources: - - url: "docker://docker.io/goharbor/notary-signer-photon@sha256:172c1607fd36d9e53d5929683910b6d3807532cafeeeea84aba3e6a0c3dd3d47" - tag: "goharbor/notary-signer-photon:v2.0.1" + - url: "docker://docker.io/goharbor/notary-signer-photon@sha256:141311d3f1609dcbaaeebcb4ba311817e92eb073fba7ba3ee540631f1dfb8321" + tag: "goharbor/notary-signer-photon:v2.0.2" -- GitLab From 975bfc29cb081f47a425a69967c251b366695931 Mon Sep 17 00:00:00 2001 From: Sean Melissari Date: Tue, 18 Aug 2020 19:38:03 -0400 Subject: [PATCH 7/7] add deployment notes --- Dockerfile | 4 ++-- README.md | 4 ++++ conf/signer-config.postgres.sample.json | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 conf/signer-config.postgres.sample.json diff --git a/Dockerfile b/Dockerfile index 569d3ec..3ddb1c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -ARG BASE_REGISTRY=nexus-docker-secure.levelup-dev.io -ARG BASE_IMAGE=ubi8 +ARG BASE_REGISTRY=registry1.dsop.io +ARG BASE_IMAGE=ironbank/redhat/ubi/ubi8 ARG BASE_TAG=8.2 FROM goharbor/notary-signer-photon:v2.0.2 as base diff --git a/README.md b/README.md index 6d45ad2..13c150a 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,7 @@ To learn more about Harbor [go to the complete documentation](https://goharbor.i ## Deployment Refer to the Helm [chart](https://repo1.dsop.io/dsop/charts/-/tree/master/harbor/harbor) for deployment instructions. + +## Notes + +The image does not contain a default `signer-config.postgres.json`. You must mount the notary configuration to `/etc/notary/signer-config.postgres.json`. If you are using Helm to deploy, the chart handles creating and mounting the config. See [the sample config](./conf/signer-config.postgres.sample.json) for an example configuration. diff --git a/conf/signer-config.postgres.sample.json b/conf/signer-config.postgres.sample.json new file mode 100644 index 0000000..014de5d --- /dev/null +++ b/conf/signer-config.postgres.sample.json @@ -0,0 +1,15 @@ +{ + "server": { + "grpc_addr": ":7899", + "tls_cert_file": "/etc/ssl/notary/tls.crt", + "tls_key_file": "/etc/ssl/notary/tls.key" + }, + "logging": { + "level": "info" + }, + "storage": { + "backend": "postgres", + "db_url": "postgres://harbor-database:5432/notarysigner?sslmode=require", + "default_alias": "defaultalias" + } +} -- GitLab