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

Mask the credentials when reading the stream config from streams API #111

Open
ye11ow opened this issue Oct 22, 2024 · 5 comments
Open

Mask the credentials when reading the stream config from streams API #111

ye11ow opened this issue Oct 22, 2024 · 5 comments
Labels
bug Something isn't working configuration Any tasks or issues relating to Benthos configuration

Comments

@ye11ow
Copy link
Contributor

ye11ow commented Oct 22, 2024

The current benthos Streams API provide a good way to dynamically create and manage the streams. However, when reading an existing stream config via GET /streams/{id} endpoint, it would be better to mask all the credential fields or at least provide an option to mask them.

For example, currently when getting a stream with azure_cosmosdb as input, the response is like this:

{
  "active": true,
  "uptime": 222.438774375,
  "uptime_str": "3m42.438774667s",
  "config": {
    "input": {
      "azure_cosmosdb": {
        "account_key": "adfs",
        "args_mapping": "root = [\n  { \"Name\": \"@name\", \"Value\": \"benthos\" },\n]",
        "auto_replay_nacks": true,
        "batch_count": -1,
        "connection_string": "sdfa",
        "container": "testcontainer",
        "database": "testdb",
        "endpoint": "https://localhost:8081",
        "partition_keys_map": "root = \"blobfish\"",
        "query": "SELECT c.foo FROM testcontainer AS c WHERE c.bar = \"baz\" AND c.timestamp < @timestamp"
      }
    },
    "output": {
      "stdout": {
        "codec": "lines"
      }
    }
  }
}

Expected response would be:

{
  "active": true,
  "uptime": 222.438774375,
  "uptime_str": "3m42.438774667s",
  "config": {
    "input": {
      "azure_cosmosdb": {
        "account_key": "!!!SECRET_SCRUBBED!!!",
        "args_mapping": "root = [\n  { \"Name\": \"@name\", \"Value\": \"benthos\" },\n]",
        "auto_replay_nacks": true,
        "batch_count": -1,
        "connection_string": "!!!SECRET_SCRUBBED!!!",
        "container": "testcontainer",
        "database": "testdb",
        "endpoint": "https://localhost:8081",
        "partition_keys_map": "root = \"blobfish\"",
        "query": "SELECT c.foo FROM testcontainer AS c WHERE c.bar = \"baz\" AND c.timestamp < @timestamp"
      }
    },
    "output": {
      "stdout": {
        "codec": "lines"
      }
    }
  }
}

Both account_key and connection_string should be masked because they are marked as secret fields in the input definations.

@ye11ow
Copy link
Contributor Author

ye11ow commented Oct 22, 2024

@Jeffail @mihaitodor Any comments regards this new feature request? If it makes sense, I can work on it 😄

@Manognya-9491
Copy link

@ye11ow , I have a similar query regarding masking the secrets. I am trying to POST a config generated to benthos streams but I would prefer to send it via an https call instead of http using cert and key file fields in http_server input

@ye11ow
Copy link
Contributor Author

ye11ow commented Nov 7, 2024

I just realized that benthos used to mask the secret before. If I read the code correctly, this feature was removed in this commit 6435bb4#diff-ac44c8bf4b1d0d06feb56fbca87b0f82d82d809c9879e50b93a2469be9bf96e8L370 (since v4.25)

The Sanitised method was removed and it just called info.Config().GetRawSource() instead. Is this on purpose? Thanks!

cc @Manognya-9491 @Jeffail @mihaitodor

@Jeffail
Copy link
Collaborator

Jeffail commented Nov 15, 2024

Hey @ye11ow, it's unintentional and probably because when the mechanism for extracting the source config as a structured value changed there was a blanket refactor. I believe there are accessible APIs for re-doing the sanitation on that data that we need to re-introduce, it'll look slightly different to the old code but functionally will be the same.

@Jeffail Jeffail added bug Something isn't working configuration Any tasks or issues relating to Benthos configuration labels Nov 15, 2024
@sarwarbhuiyan
Copy link

Did we get to the bottom of the existing feature that had been removed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working configuration Any tasks or issues relating to Benthos configuration
Projects
None yet
Development

No branches or pull requests

4 participants