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

Bugfixes for QA gold release SA-3419 #225

Merged
merged 3 commits into from
Mar 10, 2023
Merged

Bugfixes for QA gold release SA-3419 #225

merged 3 commits into from
Mar 10, 2023

Conversation

lifehackjim
Copy link
Contributor

  • axonshell asset-type saved-query add
  • axonshell asset-type saved-query copy

- axonshell asset-type saved-query add
- axonshell asset-type saved-query copy
@lifehackjim lifehackjim changed the title Bugfixes for QA gold release Bugfixes for QA gold release SA-3419 Mar 9, 2023
Jim Olsen added 2 commits March 9, 2023 19:32
## Feature: Add ability to use username and password for credentials

### Axonshell changes

A new option is available to be used at the beginning of the command line:

```text
  -creds, --credentials / -keys, --keys
                                  Treat key as Username and secret as password
                                  [env var: AX_CREDENTIALS; default: keys]
````

This option, when used like:
```
axonshell -creds devices count
```

Will treat the value stored in --key or AX_KEY as username, and the value stored in --secret or AX_SECRET as the password.

### API changes

Connect has a new argument:

```python
credentials: bool = False
```

If this is True, key is treated as username and secret is treated as password and instead of using the Auth module ApiKey, it will use the new Auth module Credentials.

Credentials logs in with username and password, then fetches the api key and secret and uses that for the duration of the session.

## Feature: Get the API keys from an Axonius instance and write them to a file

A new command group has been added to Axonshell:

```text
Usage: axonshell account [OPTIONS] COMMAND [ARGS]...

  Group: Account commands.

Options:
  --help  Show this message and exit.

Commands:
  get-api-keys              Get the API keys for the current user.
  signup                    Perform the initial signup to an instance.
  use-password-reset-token  Use a password reset token.
  write-config              Create/Update a '.env' file with url, key,...

```

The signup, use-password-reset-token, and write-config commands are just copied over from axonshell tools.

The get-api-key command is a new command altogether:

```text
Usage: axonshell account get-api-keys [OPTIONS]

  Get the API keys for the current user.

Options:
  -u, --url URL                   URL of an Axonius instance  [env var:
                                  AX_URL; required]
  -k, --key KEY                   API Key of user in an Axonius instance  [env
                                  var: AX_KEY; required]
  -s, --secret SECRET             API Secret of user in an Axonius instance
                                  [env var: AX_SECRET; required]
  -xf, --export-format [json|str|env]
                                  Format of to export data in  [env var:
                                  AX_EXPORT_FORMAT; default: str]
  -e, --env TEXT                  Path to .env file when --export-format==env
                                  [env var: AX_ENV; default: .env]
  --help                          Show this message and exit.
```

You can use this with thew new --credentials option and have it prompt you for key (provide username), prompt you for secret (provide password) then create your .env file for you:

```
axonshell -creds account get-api-keys --url 1.1.1.1 --export-format env
```

## Feature: Add log filtering to hide potential credential storage

Created a logging formatter in axonius_api_client.logs:
```python

class HideFormatter(logging.Formatter):
    """Hide the rest of the line for any lines against :attr:`HIDE_REGEX`."""

    HIDE_ENABLED: bool = True
    """Enable hiding of matches to HIDE_REGEX."""
    HIDE_REGEX: t.Pattern = re.compile(r"(password|secret).*", re.I)
    """Pattern of sensitive info to hide."""
    HIDE_REPLACE: str = r"\1 ...REST OF LINE HIDDEN..."
    """Value to replace matches to HIDE_REGEX with."""
```

If any line in the logging output contains the word password or secret, the rest of the line after those words will be hidden from the logging system.
@nate-axonius nate-axonius merged commit 74c49fe into master Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants