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

Add CWD to Git's safe.directory with cml ci #974

Merged
merged 14 commits into from
Apr 22, 2022
Merged

Conversation

0x2b3bfa0
Copy link
Member

@0x2b3bfa0 0x2b3bfa0 commented Apr 18, 2022

Fixes #970 in a rather awkward way. See this upstream pull request for the rationale for not fixing this on actions/checkout by writing the global configuration:

⚠️ This pull request modifies the Git global configuration. 🙊

@0x2b3bfa0 0x2b3bfa0 temporarily deployed to internal April 18, 2022 15:46 Inactive
@0x2b3bfa0 0x2b3bfa0 requested a review from a team April 18, 2022 15:46
@0x2b3bfa0 0x2b3bfa0 self-assigned this Apr 18, 2022
@0x2b3bfa0 0x2b3bfa0 added bug Something isn't working p0-critical Max priority (ASAP) labels Apr 18, 2022
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to internal April 18, 2022 15:47 Inactive
@dacbd
Copy link
Contributor

dacbd commented Apr 19, 2022

I feel this is a pretty safe fix considering how the tools are used. (talking about the linked rationale for the actions/checkout fix) cml and more so cml ci are run in ci/cd envs or its own created instance (cml runner) where writing an option to the global config should not be an issue.

@0x2b3bfa0
Copy link
Member Author

Agreed. The only other alternative I can think of would be creating an ephemeral home directory with a copy of the global Git configuration, like in actions/checkout#762. 🙃

src/cml.js Outdated Show resolved Hide resolved
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to internal April 20, 2022 08:58 Inactive
src/cml.js Outdated Show resolved Hide resolved
@0x2b3bfa0 0x2b3bfa0 marked this pull request as draft April 20, 2022 10:03
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to internal April 20, 2022 20:20 Inactive
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to internal April 20, 2022 20:21 Inactive
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to internal April 20, 2022 20:22 Inactive
@0x2b3bfa0 0x2b3bfa0 marked this pull request as ready for review April 20, 2022 20:23
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to internal April 20, 2022 20:23 Inactive
@0x2b3bfa0 0x2b3bfa0 enabled auto-merge (squash) April 20, 2022 20:23
@0x2b3bfa0
Copy link
Member Author

0x2b3bfa0 commented Apr 20, 2022

Not worth delaying the fix seeking perfection, but it's far from ideal. Mainly because the CML constructor already does many things it shouldn't.

@DavidGOrtega
Copy link
Contributor

Mainly because the CML constructor already does many things it shouldn't.

Should we enumerate them and fix them?

@dacbd
Copy link
Contributor

dacbd commented Apr 21, 2022

I haven't tried testing this within the GitHub Actions context, but is

error: Command failed: git config --get remote.origin.url {"output":[null,{"data":[],"type":"Buffer"},{"data":[],"type":"Buffer"}],"pid":16,"signal":null,"status":1,"stderr":{"data":[],"type":"Buffer"},"stdout":{"data":[],"type":"Buffer"}}

the expected output from a local test, see:

#!/bin/bash
git clone git@github.com:iterative/cml.git
pushd cml
git checkout git-safe-directory
npm install
docker build -t cml-local:latest .
popd
docker run --rm -it -v $PWD/cml:/home/runner cml-local:latest node ./bin/cml.js ci
rm -rf ./cml

@DavidGOrtega
Copy link
Contributor

Yes, we can do a factory to solve that error or less formal enforce to call an init method, I never liked the last idea

@0x2b3bfa0
Copy link
Member Author

Or, alternatively, treat repo as an asynchronous method (what it should be) instead of a class property. 🤔

src/cml.js Show resolved Hide resolved
src/cml.js Outdated Show resolved Hide resolved
src/cml.js Show resolved Hide resolved
src/cml.js Outdated Show resolved Hide resolved
shcheklein
shcheklein previously approved these changes Apr 22, 2022
Copy link
Member

@shcheklein shcheklein left a comment

Choose a reason for hiding this comment

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

thanks @0x2b3bfa0 for addressing this! Looks go to me it that works as a temp fix :) Let's merge (comments are not critical, esp if it's a short term fix).

Mid term:

  • do we know what are the security implications of this? What was the angle of a possible attack in the first place, can it be applied in this case with some carefully crafted PR or something?
  • do we need tests for this? or do we wait for checkout action to fix it on their end? Put a comment or create a ticket for this?

Co-authored-by: Ivan Shcheklein <shcheklein@gmail.com>
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to internal April 22, 2022 18:38 Inactive
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to internal April 22, 2022 18:41 Inactive
@dacbd dacbd added bug Something isn't working and removed bug Something isn't working labels Apr 22, 2022
@dacbd dacbd self-requested a review April 22, 2022 18:43
dacbd
dacbd previously approved these changes Apr 22, 2022
Copy link
Contributor

@dacbd dacbd left a comment

Choose a reason for hiding this comment

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

I agree with the getOrSet comment, but my test script ran as I would expect.

@0x2b3bfa0 0x2b3bfa0 temporarily deployed to internal April 22, 2022 18:46 Inactive
@0x2b3bfa0
Copy link
Member Author

0x2b3bfa0 commented Apr 22, 2022

do we need tests for this? or do we wait for checkout action to fix it on their end? Put a comment or create a ticket for this?

I would wait for GitHub Actions to fix it. Let's track any further feedback on #984.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p0-critical Max priority (ASAP)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CML initialization is broken on GH in container mode
5 participants