Commit Graph

765 Commits

Author SHA1 Message Date
Peter Hamilton 24f30d46b2 Add OrderedEnum to enable enum value comparisons
This change adds a new Enum subclass, OrderedEnum, that provides
comparison operators allowing for comparisons between enum values.
This will be used going forward with the KMIPVersion enum enabling
version checking on supported or unsupported object types.
2019-02-25 12:50:43 -05:00
Peter Hamilton 2057a48b31 Add KMIP version markers to enumerations 2019-02-22 12:03:43 -05:00
Peter Hamilton bc3e81b577 Add KMIP 2.0-style attribute handling
This change adds a new Attributes object to the object hierarchy,
which replaces TemplateAttributes in KMIP 2.0. The old attribute
components, like the AttributeName and AttributeIndex, are no
longer used and are instead replaced with the KMIP TTLV tag for
the attributes in question. This brings the attribute encoding
process in line with the rest of the KMIP specification.

To support this change, additional attribute and enumeration
utility functions have been added to simply attribute building
and attribute/enumeration validity checking. New test cases
covering this new functionality are also included.
2019-02-22 09:59:05 -05:00
Peter Hamilton e986488ebe Add KMIP 2.0 enumerations 2019-02-15 07:36:53 -05:00
Peter Hamilton dcade2a264 Update object hierarchy read/write to support the KMIP version
This change updates the PyKMIP object hierarchy's read/write
method signatures to support propagation of the KMIP version. The
introduction of KMIP 2.0 introduces future KMIP message encodings
that break backwards compatibility; to support this, PyKMIP must
know what KMIP version is being used when encoding or decoding an
object; the KMIP version residing in the client or server alone
is now insufficient. Prior versions of KMIP, namely 1.0 - 1.4,
have been backwards compatible, obviating the need for the KMIP
version at encode/decode time. Going forward, this is no longer
true.

The PyKMIP client and server have been updated to include the
KMIP version when making calls to read/write, as have the
associated test cases covering this functionality.
2019-02-06 17:06:47 -05:00
Peter Hamilton c012a430aa Fix flake8 warnings to reflect modern Python style 2019-02-01 11:53:18 -05:00
Peter Hamilton 7648ea801b Add additional session error logging for authentication failures 2019-01-29 19:18:05 -05:00
Peter Hamilton 5e212b32a3 Update the Travis CI config to output log files on test failures
This change updates the Travis CI configuration file to output the
contents of the PyKMIP server and SLUGS log files if:

* a test failure occurred, and
* the log files exist in the test environment

This makes debugging server and service failures much easier in
Travis CI, specifically during integration and functional test
suite runs.
2019-01-29 14:22:19 -05:00
Peter Hamilton f75a74922a Migrate from using assertRaisesRegexp to assertRaisesRegex 2019-01-28 10:38:05 -05:00
Peter Hamilton 4828e0d845 Fix AttributeError in client Rekey results with missing payloads
This change fixes a bug in the KMIPProxy client's support for the
Rekey operation. Specifically, if the operation fails and does not
return a payload, the client will still try to reference the
payload object when checking for TemplateAttribute data. This
causes an AttributeError since the payload is None. This change
fixes this and adds a unit test that covers this specific case.

Fixes #474
2018-12-07 08:58:36 -05:00
Peter Hamilton 8fd7eb5ab6 Clean up test requirements and remove unused dependencies 2018-12-05 15:55:40 -05:00
Peter Hamilton c5e4c4a290 Update the PyKMIP clients to support changing their KMIP version
This change updates the PyKMIP clients, adding support for getting
and setting the KMIP version they use when making KMIP requests.
You can now do:

>>> client.kmip_version

to get the KMIP version enumeration the client is using. Use:

>>> client.kmip_version = enums.KMIPVersion.KMIP_1_1

to set the KMIP version the client uses.

The client unit tests have been updated to check and cover these
changes.

Fixes #470
2018-12-04 15:01:24 -05:00
Peter Hamilton 40c064a290 Update the server to nominally support KMIP 1.3 and 1.4
This change updates the list of KMIP versions supported by the
server. While the server does not support any specific KMIP 1.3
or 1.4 features, the protocol formats are compatible across KMIP
1.0 to 1.4. Without this change, KMIP 1.3 and 1.4 requests for
older operations, like Create, Get, and Destroy, would fail.

This change also updates the server unit tests impacted by this
change.

Closes #451
2018-12-04 12:42:00 -05:00
Peter Hamilton 1a5c2ff490
Merge pull request #467 from OpenKMIP/feat/fix-pending-deprecations
Fix pending deprecation warnings caused by dependency upgrades
2018-11-16 12:32:04 -05:00
Peter Hamilton 9a5db6d5e1 Fix pending deprecation warnings caused by dependency upgrades
This change fixes various pending deprecation warnings throughout
the library caused by recent updates to different dependencies.
While PyKMIP no longer directly triggers these warnings, some
dependencies still do when run through the test suite.
2018-11-16 11:42:05 -05:00
Peter Hamilton 257fcca477
Merge pull request #466 from OpenKMIP/feat/add-python37-support
Add support for Python 3.7
2018-11-16 08:34:22 -05:00
Peter Hamilton 3e48bab13e Add support for Python 3.7
This change adds official library support for Python 3.7, including
updating the testing infrastructure for both tox and Travis CI and
updating the library package metadata in setup.py.
2018-11-15 16:28:29 -05:00
Peter Hamilton 6d58bc4093
Merge pull request #465 from OpenKMIP/tests/add-xenial-platform-testing
Add Ubuntu 16.04 LTS as a target test platform for Travis CI
2018-11-15 15:42:13 -05:00
Peter Hamilton c74d61a971 Add Ubuntu 16.04 LTS as a target test platform for Travis CI
This change adds Ubuntu 16.04 LTS (Xenial Xerus) as a target test
platform in the Travis CI configuration file. New test builds for
all unit, integration, functional, style, security, and doc checks
should now be built for Xenial during continuous integration runs.
2018-11-15 14:37:21 -05:00
Peter Hamilton cb776ac59f
Merge pull request #463 from OpenKMIP/bug/fix-invalid-escape-sequences
Remove invalid escape sequences
2018-11-15 14:30:49 -05:00
Peter Hamilton 8abe3de8cb Remove invalid escape sequences
A recent style update to Python 3.6 adds deprecation W605, which
tightens the usage of invalid escape sequences. This patch removes
any instances of invalid escape sequences from the PyKMIP code
base, bringing the library back up to compliance with Python style.
2018-11-15 13:53:06 -05:00
Peter Hamilton 0819574424
Merge pull request #458 from tipabu/eoferror-text
Change EOFError text
2018-10-10 08:51:40 -04:00
Peter Hamilton 1365047dcb
Merge pull request #457 from tipabu/secure-logging
Secure logging by default
2018-10-10 08:51:07 -04:00
Tim Burke f60bae83d0 Secure logging by default
As an application developer, you might expect to be able to turn on
debug logging at the root logger with something like

    logging.basicConfig(level=logging.DEBUG)

However, if the application needed to fetch any secrets from a KMIP
server, these previously would be logged as part of the wire protocol.
Further, any passwords in configs would also get logged at DEBUG.
Applications would need to proactively silence such logging, as in
https://github.com/openstack/swift/commit/12b6d46

Now, we will default the logger level to INFO to suppress the debug
logging. However, seeing the on-wire data may still be useful, for
example when developing a new KMIP server. So, allow developers to
consciously set the logger level to DEBUG.
2018-10-09 14:24:22 -07:00
Tim Burke 8e82438f25 Change EOFError text
The old text made perfect sense when in a server context, trying to
read requests from clients, but KMIPProtocol is also used by *clients*
to read *responses*. Let's change it to something a little more
request/response agnostic.
2018-10-09 14:05:55 -07:00
Peter Hamilton 9fc9c62887
Merge pull request #447 from tipabu/bug-381
Clean up KMIPProxy initialization and destruction
2018-06-28 11:24:45 -04:00
Peter Hamilton a931850c51
Merge pull request #446 from tipabu/improved-errors-and-logging
Improve errors and logging
2018-06-28 11:23:11 -04:00
Tim Burke d291c50bd6 Clean up KMIPProxy initialization and destruction
Fixes #381.
2018-06-22 12:26:48 -07:00
Tim Burke 8bf7592db9 Preserve the stack when re-raising connection errors 2018-06-22 12:11:16 -07:00
Tim Burke 6306846b45 Log connection error details per-host
Otherwise, you don't get much insight into why you had to settle for
your third configured host. Now, you can get information like

   An error occurred while connecting to appliance foo.bar:
      [Errno -5] No address associated with hostname
   An error occurred while connecting to appliance localhost:
      [Errno 111] Connection refused

even when we ultimately succeed in creating a client.
2018-06-22 12:11:16 -07:00
Tim Burke eb2fee80e8 Stop logging tracebacks when we're about to reraise
At that point, it's up to the caller to decide whether a stack trace is
appropriate; if the caller decides the connection error is recoverable,
us logging a traceback will only confuse things.

Also, prevent a TypeError during log interpolation by actually using the
argument we were providing.
2018-06-22 11:53:25 -07:00
Tim Burke 3d2a7edc94 Have ProxyKmipClient use a non-root logger 2018-06-22 11:07:50 -07:00
Peter Hamilton 4e138207af
Merge pull request #443 from tipabu/reraise
Reraise exceptions to preserve stack traces
2018-06-19 14:32:32 -04:00
Tim Burke 5ffb5d74f6 Reraise exceptions to preserve stack traces
Otherwise, you can hit errors with tracebacks like

   Traceback (most recent call last):
     ...
     File ".../kmip/pie/client.py", line 1573, in __enter__
       self.open()
     File ".../kmip/pie/client.py", line 135, in open
       raise e
   IOError: [Errno 2] No such file or directory

... which isn't terribly useful; it doesn't give you any information
about *what* file wasn't found. By using a bare `raise`, you preserve
the rest of the stack and get

   Traceback (most recent call last):
     ...
     File ".../kmip/pie/client.py", line 1573, in __enter__
       self.open()
     File ".../kmip/pie/client.py", line 131, in open
       self.proxy.open()
     File ".../kmip/services/kmip_client.py", line 221, in open
       self._create_socket(sock)
     File ".../kmip/services/kmip_client.py", line 246, in _create_socket
       suppress_ragged_eofs=self.suppress_ragged_eofs)
     File ".../eventlet/green/ssl.py", line 379, in wrap_socket
       return GreenSSLSocket(sock, *a, **kw)
     File ".../eventlet/green/ssl.py", line 68, in __init__
       ca_certs, do_handshake_on_connect and six.PY2, *args, **kw)
     File ".../ssl.py", line 558, in __init__
       self._context.load_verify_locations(ca_certs)
   IOError: [Errno 2] No such file or directory

... which makes it clear that it was a problem with the CA certificate
bundle.
2018-06-19 10:40:56 -07:00
Peter Hamilton f5aa6b02f5
Merge pull request #442 from OpenKMIP/feat/update-docs
Update the documentation to cover auth and access control changes
2018-06-05 17:08:31 -04:00
Peter Hamilton 91274e2557 Update the documentation to cover auth and access control changes
This change updates the server and FAQ documentation, fully
describing the changes made to the server authentication and
access control systems. Specifically, the new third-party auth
plugin system is described, along with the new group-based
operation policy structure and policy file active monitoring.

Information on running the integration and functional tests testing
these changes is included.

The FAQ is updated to point to these changes in the server docs.
The original relevant FAQ content has been removed.
2018-06-05 09:57:06 -04:00
Peter Hamilton fcae8a5048
Merge pull request #440 from OpenKMIP/feat/bump-version
Update the PyKMIP library version to 0.9.dev0
2018-05-18 11:35:56 -04:00
Peter Hamilton 829df239fc
Merge pull request #439 from OpenKMIP/release-0.8.0
PyKMIP - Release 0.8.0
2018-05-18 10:00:05 -04:00
Peter Hamilton a1985dfdef Update the PyKMIP library version to 0.9.dev0
This change updates the library version to the next dev version,
updating the changelog to reflect this change.
2018-05-17 19:23:34 -04:00
Peter Hamilton 74d24ff072 PyKMIP - Release 0.8.0
This update includes new operations and features for the client
and server, in addition to other minor updates and bug fixes:

* Add Sphinx-based client and server library documentation
* Add server support for third-party authentication systems
* Add client support for the Check operation
* Add client support for the Rekey operation
* Add client support for attestation credentials
* Add functional tests for server auth. and access control
* Add payloads for the Archive and Cancel operations
* Add payloads for the GetUsageAllocation and Poll operations
* Add payloads for the ObtainLease and Recover operations
* Update the server to support group-based operation policies
* Update the server to support live loading of policy files
* Update the server to support custom database file paths
* Update the server to raise PermissionDenied on violations
* Update the client to support custom configuration file paths
* Update the ProxyKmipClient to support Registering names
* Update the ProxyKmipClient to set usage masks for Derived keys
* Update the README to reference the new documentation
* Update the Travis CI config to test building the docs
* Update the Travis CI config to run integration tests
* Remove support for Python 3.3
* Fix a DOS bug by setting the server socket timeout
* Fix a ProxyKmipClient bug with cryptographic parameter handling
* Fix a ProxyKmipClient bug with usage mask processing
2018-05-17 16:57:38 -04:00
Peter Hamilton b878dbfdf9
Merge pull request #438 from OpenKMIP/feat/update-access-denied-error
Raise PermissionDenied on access control violations
2018-05-17 15:55:16 -04:00
Peter Hamilton 944186b1ca
Merge pull request #437 from OpenKMIP/feat/use-preset-over-default
Rename the 'default' policy section to 'preset'
2018-05-17 15:32:25 -04:00
Peter Hamilton 8b99c74d0b Raise PermissionDenied on access control violations
This change changes the error the server uses when access control
violations occur, specifically swapping from the more agnostic
ItemNotFound to the more explicit PermissionDenied. This change
better conforms with the expected behavior of a KMIP server.
2018-05-17 14:23:07 -04:00
Peter Hamilton b0bd77e0d9
Merge pull request #436 from OpenKMIP/feat/improve-attribute-error-msg
Add a better error message when reading unparseable attributes
2018-05-17 14:13:34 -04:00
Peter Hamilton 008f86cfa9 Rename the 'default' policy section to 'preset'
This change tweaks the format of operation policy files, renaming
the 'default' section of each policy to 'preset'. This reinforces
the idea that this section of the policy is used only when group-
based access control is disabled. It also removes any ambiguity
between this section of the policy and the actual 'default'
policy built into the server.
2018-05-17 13:55:50 -04:00
Peter Hamilton a9afd44a91 Add a better error message when reading unparseable attributes
This change adds a basic error message that gets raised when
attempting to read an unparseable attribute (i.e., an attribute
that is not supported by the library).

Fixes #429
2018-05-17 13:28:11 -04:00
Peter Hamilton c3319afd67
Merge pull request #434 from OpenKMIP/feat/add-auth-integration-tests
Add functional tests for server auth and access control
2018-05-10 13:59:13 -04:00
Peter Hamilton b5e7323845 Add functional tests for server auth and access control
This change adds a new integration test suite, named 'functional',
that is specifically intended to test third-party authentication
and group-based access control with the PyKMIP server. A new tox
environment is added to handle running these tests separately from
the existing 'integration' test suite. New Travis CI configuration
and setup files have also been added to facilitate running these
tests automatically.
2018-05-09 01:21:03 -04:00
Peter Hamilton 2dacdf7bd4
Merge pull request #431 from OpenKMIP/bug/fix-cert-script
Fix bug with writing bytes in the certificate script
2018-04-24 23:10:33 -04:00
Peter Hamilton 06c960236b
Merge pull request #432 from OpenKMIP/bug/fix-server-timeout
Fix a denial-of-service bug by setting the server socket timeout
2018-04-24 23:10:12 -04:00