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

ECT-1803 Security Updates #7

Merged
merged 2 commits into from
Jan 17, 2024
Merged

ECT-1803 Security Updates #7

merged 2 commits into from
Jan 17, 2024

Conversation

nhumble-sa
Copy link

Pull docker tag from git

  • Show version about to be pushed to allow time to cancel if wrong version is determined.
    • Wait 15 seconds (or for user input) before proceeding (so automated tools don't block).

docker_push.sh Outdated
VERSION="$(git describe --tags --match 'v*')" # Get version tag from git
VERSION=${VERSION#v} # Remove leading 'v'

read -p "This action will build and publish docker image version $VERSION (this will automatically proceed in 15 seconds)" -t 15

Choose a reason for hiding this comment

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

If the 15 second timeout occurs, read will return a non-zero exit status that will cause the script to terminate before the push due to set -e. Also, this will error (and terminate the script due to set -e) if stdin isn't present or has been redirected from /dev/null. I'm not sure exactly what sort of environment our automated systems might provide, but it might be safer to just echo the warning, and sleep 15.

Choose a reason for hiding this comment

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

Obviously echo + sleep 15 doesn't allow the user to quickly bypass the pause. (But hey, maybe we want people to have time to think long and hard about the push.) But if we want the bypass capability, we could do the read followed by || true so it is immune to the set -e.

Copy link

Choose a reason for hiding this comment

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

TBH, I'm not sure if I'm correct, but I guess waiting doesn't make sense in an automated setup. So, maybe provide an optional argument for the script (e.g. -b or --batch), where you just echo and run the command without waiting.

And when running without that option, you might wait for 15 seconds or you might even wait forever for user's reply.

Copy link
Author

Choose a reason for hiding this comment

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

We're not likely to use this script in automated scenarios, so it's a bit moot.

Copy link

@dsimmons-sa dsimmons-sa left a comment

Choose a reason for hiding this comment

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

Looks good to me.
Since we'll have new commits now, we can tag v1.2.6 without any worries about the "multiple tags on one commit" problem. :)

@nhumble-sa nhumble-sa merged commit fa05511 into master Jan 17, 2024
1 check passed
@nhumble-sa nhumble-sa deleted the ECT-1803-security-updates branch January 17, 2024 17:03
VERSION="1.2.5"
set -e

VERSION="$(git describe --tags --match 'v*')" # Get version tag from git
Copy link

@hedayat hedayat Jan 17, 2024

Choose a reason for hiding this comment

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

I was thinking maybe its better to have a more specific match pattern; at least making sure that 'v' is followed by a number. If we think there might be non-version tags, it's likely that a tag can be a word starting with 'v'.

Suggested change
VERSION="$(git describe --tags --match 'v*')" # Get version tag from git
VERSION="$(git describe --tags --match 'v[[:digit:]]*')" # Get version tag from git

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, didn't see this until now. The match flag takes a glob, not a regex.

--match <pattern>
           Only consider tags matching the given glob(7) pattern, excluding the "refs/tags/" prefix.

Copy link

Choose a reason for hiding this comment

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

Sorry for the late comment. Yeah, if it was a regex we could actually match the complete version pattern. But, that's also a glob pattern to just match the first character of the tag after 'v' to be a number. According to 'man 7 glob', the [[:digit:]] pattern is also recognized, so I used it instead of [0-9] range.

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.

4 participants