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

Support getting package versions from other files #3061

Open
suzuki-shunsuke opened this issue Aug 24, 2024 · 6 comments · May be fixed by #3363
Open

Support getting package versions from other files #3061

suzuki-shunsuke opened this issue Aug 24, 2024 · 6 comments · May be fixed by #3363
Labels
enhancement New feature or request

Comments

@suzuki-shunsuke
Copy link
Member

suzuki-shunsuke commented Aug 24, 2024

Feature Overview

Similar to #2632 .

Support getting package versions from other files.

  • .terraform-version, .nvmrc, .node-version
  • Get a version from JSON, YAML, TOML using JSONPath or something

Why is the feature needed?

To share the version definition with other tools.
To make DRY.

Workaround

No response

Example Code

- name: hashicorp/terraform
  version: file(".terraform-version")

Note

@suzuki-shunsuke
Copy link
Member Author

suzuki-shunsuke commented Dec 15, 2024

expr

version_expr: |
  readJSON("foo.json").version
version_expr: |
  readYAML("foo.yaml").version
version_expr: |
  "v" + readFile(".terraform-version")

@suzuki-shunsuke
Copy link
Member Author

suzuki-shunsuke commented Dec 15, 2024

⚠️ Security Concern

Malicious users may be able to expose secrets via log by reading secret files via version_expr.

e.g.

version_expr: readFile("/home/foo/.aws/credentials")

@suzuki-shunsuke
Copy link
Member Author

suzuki-shunsuke commented Dec 15, 2024

Solution

Restrict the value of version_expr to semver.
This prevents secrets from being exposed.

https://pkg.go.dev/github.com/hashicorp/go-version#NewSemver

We can complement a prefix such as cli- by version_expr_prefix.

@suzuki-shunsuke
Copy link
Member Author

suzuki-shunsuke commented Dec 15, 2024

template

version_template: |
  {{(readJSON "foo.json").version}}
version_template: |
  {{(readYAML "foo.yaml").version}}'
version_template: |
  v{{readFile ".terraform-version"}}

@suzuki-shunsuke
Copy link
Member Author

I'm wondering if this feature is really necessary.

Why is the feature needed?
To share the version definition with other tools.
To make DRY.

This makes sense, but actually I don't have strong motivation.

@suzuki-shunsuke
Copy link
Member Author

semver's pre-release can include secrets, so we need to restrict the pattern of pre-release.

1.0
1.0.0
1.0.0-alpha
1.0.0-rc.1

^v?\d+\.\d+(\.\d+)*[.-]?((alpha|beta|dev|rc)[.-]?)?\d*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant