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

Exec source #125

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Exec source #125

wants to merge 4 commits into from

Conversation

jhbigler
Copy link

@jhbigler jhbigler commented Jun 12, 2022

Mentioned in #126: An additional ACL source of truth that calls some executable on the system and uses the CSV or YAML from the stdout. This can be useful for a user that wants to use a source type that is not implemented in the other source types and does not want to implement it in Scala and have to rebuild the security manager. The executable can be written in any language (Python, Perl, Ruby, etc), as long as it can be called from a command shell.

Hypothetical use cases:

  • User wants to use a table in a database (MySQL, Postgres, etc)
  • User wants to use an Elasticsearch index
  • User wants to use a directory of CSV/YAML files (as opposed to a single file)
  • User wants to use multiple source types

The user would be responsible for creating the executable to generate the CSV/YAML as needed.

Use:

  • SOURCE_EXEC_CMD: Full path to the executable
  • SOURCE_EXEC_ARGS: Arguments passed to the executable, they will be split by the below separator value. Defaults to ''
  • SOURCE_EXEC_ARGS_SEP: String separator to split the argument value. Defaults to ','. For example, setting the args to 'a,b,c,d' and the separator to ',' will pass in the args [a, b, c, d] to the executable
  • SOURCE_EXEC_PARSER: 'yaml' or 'csv', defaults to 'yaml'

Example:

  • SOURCE_EXEC_CMD=/usr/sbin/myscript.py
  • SOURCE_EXEC_ARGS=--dburi;postgres://postgres:123456@127.0.0.1:5432/dummy
  • SOURCE_EXEC_ARGS_SEP=';'
  • SOURCE_EXEC_PARSER=csv
  • Results in the security manager calling '/usr/sbin/myscript.py --dburi postgres://postgres:123456@127.0.0.1:5432/dummy' and parsing the csv from the stdout on every refresh

Notes:

  • Assumes SOURCE_EXEC_CMD exists - probably best idea to use a full path to ensure the security manager sees it
  • The source will return None on a non-zero exit status
  • The test cases I wrote assume a UNIX-like environment (calls /bin/cat and /bin/false)
  • The user will need to keep in mind the potential performance impacts - the executable will be called every single refresh. Perhaps set a larger value for the refresh frequency if this is a concern.
  • The security of the executable is the responsibility of the user :)

Please note - I am new to Scala and this is also my first contribution to open-source software. I am open to any and all feedback (even criticism - preferably constructive :) )

@simplesteph simplesteph requested a review from a team June 13, 2022 09:59
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.

1 participant