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

638-rebased #1

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b38b805
Use assertEqual instead of assertEquals for Python 3.11 compatibility.
tirkarthi Oct 17, 2021
69b127c
Add a Subject Alternative Name to the example server cert.
arp102 Feb 17, 2022
4d1e9c6
Repair some demos
ktrushin May 8, 2022
b781495
Copy README.rst to long_description
tipabu Sep 22, 2021
a7a5f37
Bump codeql action v1 tov2
satyakommula96 Jun 7, 2022
8a2289c
custom attributes for SymmetricKey
pranathil Sep 8, 2021
19a901d
add custom attribute support
pranathil Oct 18, 2021
95b5470
add app_specific_info
pranathil Oct 18, 2021
20f20b0
Code consistency updated
gracelombardi Jul 8, 2022
1773fba
Updated client integration tests, Added test for Application Specific…
gracelombardi Jul 12, 2022
124f7db
Updated test for App Specific Info for Symmetric Key and added test f…
gracelombardi Jul 14, 2022
5920dca
Removed uneeded important and code cleanup
gracelombardi Jul 14, 2022
6bf55b9
Added app_specific_info to init comments
gracelombardi Jul 14, 2022
0a3e391
Updated app specific info to be a list of dictionaries, removed unnee…
gracelombardi Jul 18, 2022
652d5ca
Add cryptography >= 39.0.0 support
danigm Jan 26, 2023
a339b97
Update enums.py
dsmith-qlik Sep 19, 2022
155c050
Update attribute_values.py
dsmith-qlik Sep 19, 2022
263cb34
Fix source code style to comply with PEP8
ktrushin Mar 27, 2023
fc59173
check if shared_ciphers() is None before logging
kevinAlbs Jun 23, 2023
1a0f63a
add original
locula Jun 14, 2023
5f34bae
Do not leak database connections
dutow Apr 12, 2023
f0a44b2
Fix pykmip client error with server_correlation_value issue
xlitao Apr 28, 2023
0b63de9
Fix test_mac_with_cryptographic_failure unit test.
arp102 Aug 8, 2023
111f1e5
Run travis.yml workflow
justin-h-loi Jul 31, 2023
4c65eb8
Changing file path of .travis workflow
justin-h-loi Aug 1, 2023
142ee4f
Added converted git action version of travis.yml
justin-h-loi Aug 1, 2023
4698649
.travis.yml build fix
justin-h-loi Aug 1, 2023
a7d035e
Directory fix in .travis.yml action
justin-h-loi Aug 1, 2023
2eb3f78
Permissions fix in .travis.yml action
justin-h-loi Aug 1, 2023
fd25dda
Setup virtualenv inside builds in .travis.yml action
justin-h-loi Aug 1, 2023
059e8c4
Add missing virtualenv install for builds in .travis.yml action
justin-h-loi Aug 1, 2023
01b3e54
Backtrack to try using sudo instead for setup in .travis.yml action
justin-h-loi Aug 1, 2023
7339254
File permissions for run.sh in .travis.yml action
justin-h-loi Aug 1, 2023
4041e77
Folder permissions for run.sh in .travis.yml action
justin-h-loi Aug 1, 2023
8692e34
Remove setup.py in .travis setup
justin-h-loi Aug 1, 2023
ec5f138
code reduction
justin-h-loi Aug 1, 2023
77620f3
Changing ubuntu image versions
justin-h-loi Aug 1, 2023
8f681ba
Changing python versions
justin-h-loi Aug 1, 2023
5fbf13f
Adding test number conditions
justin-h-loi Aug 1, 2023
19c57b2
Reformat test number conditions
justin-h-loi Aug 1, 2023
f7043f7
test number conditions
justin-h-loi Aug 1, 2023
11db2e5
test number conditions
justin-h-loi Aug 1, 2023
66e7b33
test reduction
justin-h-loi Aug 1, 2023
0fd1e1f
Remove old installs and attempt at doc test fix
justin-h-loi Aug 8, 2023
a102151
tox passenv change
justin-h-loi Aug 8, 2023
bfa3c01
Extending flake8 test max line length
justin-h-loi Aug 8, 2023
084fbcd
Make unit tests use default config
justin-h-loi Aug 15, 2023
ff69f85
pep8 fixes
justin-h-loi Aug 15, 2023
483fc6c
alternate config unit test fix
justin-h-loi Aug 15, 2023
ab580ee
Adding integration tests to git actions
justin-h-loi Aug 22, 2023
7299fa7
Removing setup.py install for test
justin-h-loi Aug 22, 2023
0cf89eb
Readding setup.py and adding permissions to /usr/local/lib/
justin-h-loi Aug 22, 2023
6130e18
Update git actions to node16 runtime
justin-h-loi Aug 22, 2023
8783e88
Adding ubuntu20 and extra python versions to git actions
justin-h-loi Aug 22, 2023
d275a68
(tox.ini): Forgot to add python versions to tox envlist
justin-h-loi Aug 22, 2023
8800e0b
Test fix
justin-h-loi Aug 22, 2023
4f8b316
Fix to include integration tests for py builds
justin-h-loi Aug 22, 2023
e9a63e2
Actions file name change and fixes
justin-h-loi Aug 29, 2023
a664187
Fix code syntax and docs
justin-h-loi Aug 29, 2023
400c29b
Removing bandit/pyaml version requirements
justin-h-loi Aug 29, 2023
848f88d
fixed SymmetricKey __repr__
Oct 16, 2020
e6b32b2
Update unit test - changed SymmetricKey repr.
arp102 Sep 12, 2023
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
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -50,7 +50,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -64,4 +64,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
41 changes: 41 additions & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "tox.yml"

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ${{ matrix.os }}
env:
TOXENV: ${{ matrix.test }}
RUN_INTEGRATION_TESTS: ${{ matrix.test_number}}
steps:
- uses: actions/checkout@v3
- run: pip install "tox"
- run: pip install bandit
- run: pip install codecov
- run: pip install slugs
- run: sudo chmod -R 777 /usr/local/lib/
- run: python3 setup.py install
- run: ./.travis/run.sh
- run: codecov
strategy:
matrix:
test: ["pep8", "bandit", "docs"]
os: [ubuntu-22.04,ubuntu-20.04]
include:
- test: "py38"
test_number: "0"
os: ubuntu-20.04
- test: "py38"
test_number: "1"
os: ubuntu-20.04
- test: "py310"
test_number: "0"
os: ubuntu-22.04
- test: "py310"
test_number: "1"
os: ubuntu-22.04
12 changes: 8 additions & 4 deletions .travis/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
set -e
set -x

pkill -f run_server.py || true
sleep 1

if [[ "${RUN_INTEGRATION_TESTS}" == "1" ]]; then
sudo mkdir -p /etc/pykmip/certs
sudo mkdir -p /etc/pykmip/policies
Expand All @@ -12,9 +15,10 @@ if [[ "${RUN_INTEGRATION_TESTS}" == "1" ]]; then
sudo cp ./.travis/pykmip.conf /etc/pykmip/pykmip.conf
sudo cp ./.travis/server.conf /etc/pykmip/server.conf
sudo cp ./.travis/policy.json /etc/pykmip/policies/policy.json
sudo mkdir /var/log/pykmip
sudo mkdir -p /var/log/pykmip
sudo chmod 777 /var/log/pykmip
python ./bin/run_server.py &
sudo chmod -R 777 /etc/pykmip/
python3 ./bin/run_server.py &
tox -e integration -- --config client
elif [[ "${RUN_INTEGRATION_TESTS}" == "2" ]]; then
# Set up the SLUGS instance
Expand All @@ -23,9 +27,9 @@ elif [[ "${RUN_INTEGRATION_TESTS}" == "2" ]]; then

# Set up the PyKMIP server
cp -r ./.travis/functional/pykmip /tmp/
python ./bin/create_certificates.py
python3 ./bin/create_certificates.py
mv *.pem /tmp/pykmip/certs/
sudo mkdir /var/log/pykmip
sudo mkdir -p /var/log/pykmip
sudo chmod 777 /var/log/pykmip
pykmip-server -f /tmp/pykmip/server.conf -l /tmp/pykmip/server.log &

Expand Down
2 changes: 1 addition & 1 deletion .travis/server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ port=5696
certificate_path=/etc/pykmip/certs/cert.pem
key_path=/etc/pykmip/certs/key.pem
ca_path=/etc/pykmip/certs/cert.pem
auth_suite=Basic
auth_suite=TLS1.2
enable_tls_client_auth=False
policy_path=/etc/pykmip/policies/
12 changes: 10 additions & 2 deletions bin/create_certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def create_certificate(subject_name,
signing_certificate,
signing_key,
days_valid=365,
client_auth=False):
client_auth=False,
hostname=None):
subject = x509.Name([
x509.NameAttribute(x509.NameOID.ORGANIZATION_NAME, u"Test, Inc."),
x509.NameAttribute(x509.NameOID.COMMON_NAME, subject_name)
Expand All @@ -72,6 +73,12 @@ def create_certificate(subject_name,
critical=True
)

if hostname:
builder = builder.add_extension(
x509.SubjectAlternativeName([x509.DNSName(hostname)]),
critical=False,
)

certificate = builder.sign(
signing_key,
hashes.SHA256(),
Expand All @@ -92,7 +99,8 @@ def main():
u"Server Certificate",
server_key,
root_certificate,
root_key
root_key,
hostname=u"localhost"
)

john_doe_client_key = create_rsa_private_key()
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
3 changes: 3 additions & 0 deletions kmip/core/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ class AttributeType(enum.Enum):
KEY_VALUE_LOCATION = 'Key Value Location'
ORIGINAL_CREATION_DATE = 'Original Creation Date'
SENSITIVE = "Sensitive"
ALWAYS_SENSITIVE = 'Always Sensitive'
EXTRACTABLE = 'Extractable'
NEVER_EXTRACTABLE = 'Never Extractable'


class AuthenticationSuite(enum.Enum):
Expand Down
8 changes: 8 additions & 0 deletions kmip/core/factories/attribute_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,16 @@ def create_attribute_value(self, name, value):
return primitives.DateTime(value, enums.Tags.LAST_CHANGE_DATE)
elif name is enums.AttributeType.SENSITIVE:
return primitives.Boolean(value, enums.Tags.SENSITIVE)
elif name is enums.AttributeType.ALWAYS_SENSITIVE:
return primitives.Boolean(value, enums.Tags.ALWAYS_SENSITIVE)
elif name is enums.AttributeType.EXTRACTABLE:
return primitives.Boolean(value, enums.Tags.EXTRACTABLE)
elif name is enums.AttributeType.NEVER_EXTRACTABLE:
return primitives.Boolean(value, enums.Tags.NEVER_EXTRACTABLE)
elif name is enums.AttributeType.CUSTOM_ATTRIBUTE:
return attributes.CustomAttribute(value)
elif name is enums.AttributeType.ORIGINAL_CREATION_DATE:
return primitives.DateTime(value, enums.Tags.ORIGINAL_CREATION_DATE)
else:
if not isinstance(name, str):
raise ValueError('Unrecognized attribute type: '
Expand Down
7 changes: 7 additions & 0 deletions kmip/core/messages/contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,13 @@ def __init__(self):
super(MessageExtension, self).__init__(enums.Tags.MESSAGE_EXTENSION)


# 6.19
class ServerCorrelationValue(TextString):
def __init__(self, value=None):
super(ServerCorrelationValue, self).__init__(
value, enums.Tags.SERVER_CORRELATION_VALUE)


# 9.1.3.2.2
class KeyCompressionType(Enumeration):

Expand Down
8 changes: 7 additions & 1 deletion kmip/core/messages/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,14 @@ def __init__(self,
protocol_version=None,
time_stamp=None,
batch_count=None,
server_hashed_password=None):
server_hashed_password=None,
server_correlation_value=None):
super(ResponseHeader, self).__init__(tag=Tags.RESPONSE_HEADER)
self.protocol_version = protocol_version
self.time_stamp = time_stamp
self.batch_count = batch_count
self.server_hashed_password = server_hashed_password
self.server_correlation_value = server_correlation_value

self.validate()

Expand Down Expand Up @@ -204,6 +206,10 @@ def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
server_hashed_password.read(tstream, kmip_version=kmip_version)
self._server_hashed_password = server_hashed_password

if self.is_tag_next(enums.Tags.SERVER_CORRELATION_VALUE, tstream):
self.server_correlation_value = contents.ServerCorrelationValue()
self.server_correlation_value.read(tstream, kmip_version=kmip_version)

self.batch_count = contents.BatchCount()
self.batch_count.read(tstream, kmip_version=kmip_version)

Expand Down
4 changes: 2 additions & 2 deletions kmip/core/messages/payloads/discover_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
)
tstream = BytearrayStream(istream.read(self.length))

while(self.is_tag_next(enums.Tags.PROTOCOL_VERSION, tstream)):
while (self.is_tag_next(enums.Tags.PROTOCOL_VERSION, tstream)):
protocol_version = ProtocolVersion()
protocol_version.read(tstream, kmip_version=kmip_version)
self.protocol_versions.append(protocol_version)
Expand Down Expand Up @@ -99,7 +99,7 @@ def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
)
tstream = BytearrayStream(istream.read(self.length))

while(self.is_tag_next(enums.Tags.PROTOCOL_VERSION, tstream)):
while (self.is_tag_next(enums.Tags.PROTOCOL_VERSION, tstream)):
protocol_version = ProtocolVersion()
protocol_version.read(tstream, kmip_version=kmip_version)
self.protocol_versions.append(protocol_version)
Expand Down
28 changes: 16 additions & 12 deletions kmip/core/messages/payloads/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
local_buffer = utils.BytearrayStream(input_buffer.read(self.length))

query_functions = []
while(self.is_tag_next(enums.Tags.QUERY_FUNCTION, local_buffer)):
while (self.is_tag_next(enums.Tags.QUERY_FUNCTION, local_buffer)):
query_function = primitives.Enumeration(
enums.QueryFunction,
tag=enums.Tags.QUERY_FUNCTION
Expand Down Expand Up @@ -709,7 +709,7 @@ def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
local_buffer = utils.BytearrayStream(input_buffer.read(self.length))

operations = []
while(self.is_tag_next(enums.Tags.OPERATION, local_buffer)):
while (self.is_tag_next(enums.Tags.OPERATION, local_buffer)):
operation = primitives.Enumeration(
enums.Operation,
tag=enums.Tags.OPERATION
Expand All @@ -719,7 +719,7 @@ def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
self._operations = operations

object_types = []
while(self.is_tag_next(enums.Tags.OBJECT_TYPE, local_buffer)):
while (self.is_tag_next(enums.Tags.OBJECT_TYPE, local_buffer)):
object_type = primitives.Enumeration(
enums.ObjectType,
tag=enums.Tags.OBJECT_TYPE
Expand Down Expand Up @@ -747,7 +747,7 @@ def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
self._server_information = server_information

application_namespaces = []
while(self.is_tag_next(
while (self.is_tag_next(
enums.Tags.APPLICATION_NAMESPACE,
local_buffer
)
Expand All @@ -761,7 +761,7 @@ def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):

if kmip_version >= enums.KMIPVersion.KMIP_1_1:
extensions_information = []
while(self.is_tag_next(
while (self.is_tag_next(
enums.Tags.EXTENSION_INFORMATION,
local_buffer
)
Expand All @@ -776,7 +776,11 @@ def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):

if kmip_version >= enums.KMIPVersion.KMIP_1_2:
attestation_types = []
while(self.is_tag_next(enums.Tags.ATTESTATION_TYPE, local_buffer)):
while (self.is_tag_next(
enums.Tags.ATTESTATION_TYPE,
local_buffer
)
):
attestation_type = primitives.Enumeration(
enums.AttestationType,
tag=enums.Tags.ATTESTATION_TYPE
Expand All @@ -787,14 +791,14 @@ def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):

if kmip_version >= enums.KMIPVersion.KMIP_1_3:
rngs_parameters = []
while(self.is_tag_next(enums.Tags.RNG_PARAMETERS, local_buffer)):
while (self.is_tag_next(enums.Tags.RNG_PARAMETERS, local_buffer)):
rng_parameters = objects.RNGParameters()
rng_parameters.read(local_buffer, kmip_version=kmip_version)
rngs_parameters.append(rng_parameters)
self._rng_parameters = rngs_parameters

profiles_information = []
while(self.is_tag_next(
while (self.is_tag_next(
enums.Tags.PROFILE_INFORMATION,
local_buffer
)
Expand All @@ -808,7 +812,7 @@ def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
self._profile_information = profiles_information

validations_information = []
while(self.is_tag_next(
while (self.is_tag_next(
enums.Tags.VALIDATION_INFORMATION,
local_buffer
)
Expand All @@ -822,7 +826,7 @@ def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
self._validation_information = validations_information

capabilities_information = []
while(self.is_tag_next(
while (self.is_tag_next(
enums.Tags.CAPABILITY_INFORMATION,
local_buffer
)
Expand All @@ -836,7 +840,7 @@ def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
self._capability_information = capabilities_information

client_registration_methods = []
while(self.is_tag_next(
while (self.is_tag_next(
enums.Tags.CLIENT_REGISTRATION_METHOD,
local_buffer
)
Expand All @@ -862,7 +866,7 @@ def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
self._defaults_information = defaults_information

protection_storage_masks = []
while(self.is_tag_next(
while (self.is_tag_next(
enums.Tags.PROTECTION_STORAGE_MASK,
local_buffer
)
Expand Down
2 changes: 1 addition & 1 deletion kmip/demos/pie/register_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if __name__ == '__main__':
logger = utils.build_console_logger(logging.INFO)

parser = utils.build_cli_parser()
parser = utils.build_cli_parser(enums.Operation.REGISTER)
opts, args = parser.parse_args(sys.argv[1:])

config = opts.config
Expand Down
2 changes: 1 addition & 1 deletion kmip/demos/pie/register_opaque_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if __name__ == '__main__':
logger = utils.build_console_logger(logging.INFO)

parser = utils.build_cli_parser()
parser = utils.build_cli_parser(enums.Operation.REGISTER)
opts, args = parser.parse_args(sys.argv[1:])

config = opts.config
Expand Down
2 changes: 1 addition & 1 deletion kmip/demos/pie/register_private_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if __name__ == '__main__':
logger = utils.build_console_logger(logging.INFO)

parser = utils.build_cli_parser()
parser = utils.build_cli_parser(enums.Operation.REGISTER)
opts, args = parser.parse_args(sys.argv[1:])

config = opts.config
Expand Down
2 changes: 1 addition & 1 deletion kmip/demos/pie/register_public_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if __name__ == '__main__':
logger = utils.build_console_logger(logging.INFO)

parser = utils.build_cli_parser()
parser = utils.build_cli_parser(enums.Operation.REGISTER)
opts, args = parser.parse_args(sys.argv[1:])

config = opts.config
Expand Down
Loading