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

Read workflow_settings.yaml #1580

Merged
merged 13 commits into from
Nov 20, 2023
Merged

Read workflow_settings.yaml #1580

merged 13 commits into from
Nov 20, 2023

Conversation

Ekrekr
Copy link
Contributor

@Ekrekr Ekrekr commented Nov 16, 2023

This means:

  • Implementing a way of loading YAML as JS objects via require.
  • Converting these to project configs.
  • Adding tests for main, as that's where this loading and conversion happens.
  • To test via main, a Node VM has to be used to apply the override for require.

@Ekrekr Ekrekr changed the title Read workflow settings Read workflow_settings.yaml Nov 16, 2023
core/compilers.ts Show resolved Hide resolved
@Ekrekr Ekrekr requested a review from BenBirt November 16, 2023 18:44
core/compilation_sql/BUILD Show resolved Hide resolved
core/compilers.ts Outdated Show resolved Hide resolved
core/compilers.ts Show resolved Hide resolved
core/index.ts Outdated
@@ -19,4 +20,4 @@ const supportedFeatures = [dataform.SupportedFeatures.ARRAY_BUFFER_IPC];

// These exports constitute the public API of @dataform/core.
// Changes to these will break @dataform/api, so take care!
export { compiler, main, session, supportedFeatures, version };
export { compiler, main, readWorkflowSettings, session, supportedFeatures, version };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you are exposing this to call it from the CLI and/or closed-source... i would strongly recommend not doing that.

it exposes the caller to hacked versions of @dataform/core which could do anything in readWorkflowSettings. yes, it can still be run in a sandbox, but why expose yourself to a hacked version when the caller could just read the YAML directly and trust that it reads what is actually there?

Copy link
Contributor Author

@Ekrekr Ekrekr Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's really security implications here:

  • CLI callers are always potentially exposed to hacked versions of dependencies in their node_modules, I don't see why this makes it any more or less secure.
  • Closed source will run it using the same sandbox as main is invoked from.

the caller could just read the YAML directly

I don't want to do this in two places. It means reading the YAML, converting it to JSON, and then validating that the proto is correct. Doing it in one place makes it a lot more consistent and less work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, agreed, there are no (immediate) security implications here - I didn't say that.

The point is that it is useful to be able to read files and trust what you read. If a caller (outside of @dataform/core) wants to read workflow_settings.yaml, presumably it wants to read what is actually there, not (potentially) something else entirely.

I feel pretty strongly we should not be using this function outside of @dataform/core, for that reason alone.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can sort of buy that, but it would be weird for a user to call main from a different Node context to readWorkflowSettings.

I've removed the export for now anyway, and will see if I can find a workaround for restricting the warehouse, that doesn't require calling that function first or changing the request to the compiler.

core/workflow_settings.ts Outdated Show resolved Hide resolved
core/workflow_settings.ts Outdated Show resolved Hide resolved
@Ekrekr Ekrekr requested a review from BenBirt November 20, 2023 12:48
@Ekrekr Ekrekr merged commit 14f6562 into main_v3 Nov 20, 2023
4 checks passed
@Ekrekr Ekrekr deleted the read-workflow-settings branch November 20, 2023 15:40
moker-spaghetti pushed a commit to moker-spaghetti/dataform that referenced this pull request May 26, 2024
* Add base dir structure for reading workflow settings, some cleanup

* Add a basic workflow_settings reader

* Progress with loading YAML via require

* Working YAML reader for workflow settings

* Tidying

* Cleanup bits

* Fix relative path for requiring workflow settings

* Fix import orders and lint errors

* Stop exporting getWorkflowSettings

* Move TSLint comment locations

* Add explicit include for new compilation_sql BUILD file to cli/api

* Fix compilation sql visibility
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

2 participants