Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v2.6.0 #657

Merged
merged 13 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ jobs:
"regular",
"cosign",
"multi-cosigned",
"rekor-cosigned",
"namespace-val",
"deployment",
"pre-config",
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: 'python'

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
4 changes: 4 additions & 0 deletions .github/workflows/dockerhub-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@ jobs:
run: DOCKER_CONTENT_TRUST=0 docker pull docker.io/securesystemsengineering/testimage:multi-cosigned-charlie-alice
- name: Check Cosign multisigner test image signed by alice, bob and charlie
run: DOCKER_CONTENT_TRUST=0 docker pull docker.io/securesystemsengineering/testimage:multi-cosigned-alice-bob-charlie
- name: Check Cosign cosigned testimage not in rekor log
run: DOCKER_CONTENT_TRUST=0 docker pull docker.io/securesystemsengineering/testimage:rekor-cosigned-notl
- name: Check Cosign cosigned testimage in rekor log
run: DOCKER_CONTENT_TRUST=0 docker pull docker.io/securesystemsengineering/testimage:rekor-cosigned-tl
- name: Check alerting endpoint image
run: DOCKER_CONTENT_TRUST=0 docker pull docker.io/securesystemsengineering/alerting-endpoint
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NAMESPACE = connaisseur
IMAGE := $(shell yq e '.deployment.image' helm/values.yaml)
COSIGN_VERSION = 1.7.2
COSIGN_VERSION = 1.8.0

.PHONY: all docker install uninstall upgrade annihilate

Expand All @@ -19,6 +19,9 @@ install:
#
helm install connaisseur helm --atomic --create-namespace --namespace $(NAMESPACE)

dev-install:
helm install --set deployment.replicasCount=1,deployment.imagePullPolicy=Never connaisseur helm --atomic --create-namespace --namespace $(NAMESPACE)

uninstall:
helm uninstall connaisseur -n $(NAMESPACE)
kubectl delete ns $(NAMESPACE)
Expand Down
28 changes: 0 additions & 28 deletions connaisseur/crypto.py

This file was deleted.

4 changes: 4 additions & 0 deletions connaisseur/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class UnknownAPIVersionError(UnknownTypeException):
pass


class WrongKeyError(UnknownTypeException):
pass


class AmbiguousDigestError(BaseConnaisseurException):
pass

Expand Down
6 changes: 5 additions & 1 deletion connaisseur/res/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@
},
"then": {
"properties": {
"host": {
"type": "string",
"pattern": "(https?:\\/\\/)?(([a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5})|(localhost))(:[0-9]{1,5})?(\\/.*)?"
},
"trust_roots": {
"type": "array",
"items": {
Expand Down Expand Up @@ -236,4 +240,4 @@
"validators",
"policy"
]
}
}
90 changes: 90 additions & 0 deletions connaisseur/trust_root.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import base64
import re

import ecdsa
import rsa

from connaisseur.exceptions import InvalidFormatException

KMS_REGEX = r"^(awskms|gcpkms|azurekms|hashivault|k8s):\/{2,3}[a-zA-Z0-9_.+\/:-]+$"
KEYLESS_REGEX = r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"


class TrustRootInterface:
"""
Interface from which all trust roots inherit.
"""

def __new__(cls, data: object):
instance = super(TrustRootInterface, cls).__new__(cls)
instance.__init__(data)
return instance

def __init__(self, data: object) -> None:
self.value = data

def __str__(self) -> str:
return self.value


class TrustRoot(TrustRootInterface):
"""
Abstract TrustRoot class used to represent key material or similar entities, used in
verification processes.

May contain a public key, reference to a key or any other type of trust root.
"""

value: object

def __new__(cls, data: str):
try:
tr_cls, tr_data = TrustRoot.__get_type_cls_and_data(data)
return tr_cls.__new__(tr_cls, tr_data)
except Exception as err:
msg = "Error loading the trust root."
raise InvalidFormatException(message=msg) from err

@staticmethod
def __get_type_cls_and_data(data: str):
if re.match(KEYLESS_REGEX, data):
return KeyLessTrustRoot, data
elif re.match(KMS_REGEX, data):
return KMSKey, data
elif key := TrustRoot.__check_and_return_ecdsa(data):
return ECDSAKey, key
elif key := TrustRoot.__check_and_return_rsa(data):
return RSAKey, key
return None, data

@staticmethod
def __check_and_return_ecdsa(data: str):
try:
return ecdsa.VerifyingKey.from_pem(data)
except Exception:
return None

@staticmethod
def __check_and_return_rsa(data: str):
try:
return rsa.PublicKey.load_pkcs1_openssl_pem(data)
except Exception:
return None


class ECDSAKey(TrustRootInterface):
def __str__(self) -> str:
return base64.b64encode(self.value.to_der()).decode("utf-8")


class RSAKey(TrustRootInterface):
def __str__(self) -> str:
return base64.b64encode(self.value.save_pkcs1("DER")).decode("utf-8")


class KMSKey(TrustRootInterface):
pass


class KeyLessTrustRoot(TrustRootInterface):
pass
Loading