-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Explicitly run coveralls step #2306
Conversation
.ci/.azure-pipelines-steps.yml
Outdated
@@ -11,7 +11,7 @@ steps: | |||
- script: npm install | |||
displayName: npm install | |||
|
|||
- script: npm run coveralls | |||
- script: npm run cover && istanbul-coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damccorm With this change, couldn't they change the npm run cover
command and have access?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes 🤦♂️ Updated appropriately, sorry about that
@@ -11,7 +11,7 @@ steps: | |||
- script: npm install | |||
displayName: npm install | |||
|
|||
- script: npm run coveralls | |||
- script: istanbul cover _mocha --report lcovonly && istanbul-coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I'm being a little paranoid here but what would happen if someone changed the package.json
to point istanbul
or istanbul-coveralls
at some git repository that replaced the commands with something that dumped the env?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can someone do that? My understanding of how npm works is that it makes that sort of behavior impossible. They'd have to change the dependency name in package.json
at which point it would no longer be added to the path as Istanbul
or Istanbul-coveralls
, it would get added as something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm allowed to do something like:
{
"devDependencies": {
"istanbul": "github:phated/malicious-package"
}
}
And as long as "malicious-package" contained an istanbul
bin, it'd run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this step needs to forcefully install the packages from npm. We can probably achieve that by using npx --ignore-existing istanbul && npx --ignore-existing istanbul-coveralls
- Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see what you mean now - I guess that could be an issue. I think that solution should work in theory, I'm having a bit of trouble getting it to work though because it looks like npx doesn't work correctly on lower versions of npm or Node - see build here.
We can keep looking for a solution here, to be honest I'm not sure how necessary this is though. I don't think there's anything a malicious actor could do with this token outside of messing with your code coverage results - the work to do that seems to far outweighs the benefits, especially since you can just regen the token and delete the bad builds. In the codecov docs they don't even recommend keeping it as a secret variable even though this would affect all CI's outside of Travis and I think most repos that use this without Travis just keep it as plaintext.
If you want I can keep trying to tweak npx though, I'm happy to continue to work on this if we think its worthwhile. Just don't want to overcomplicate things if we don't need to.
@damccorm this issue is referring only to azure pipelines integration, right? because Travis CI doesn't provide token access to forks. |
I'm not sure. I think they might actually just automatically inject the COVERALLS_REPO_TOKEN into their builds in which case it would be an issue, but they might have a more tightly integrated approach. I don't know exactly how this works on their end. |
@damccorm I'm having a really hard time getting coveralls to work correctly. They need a unique ID that represents the entire job and then individual job IDs to group under the top-level job. I don't see anything like that in https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml |
I think we can definitely use |
@damccorm I was able to get this to work with these environment variables: gulp/.ci/.azure-pipelines-steps.yml Lines 19 to 30 in b2c6c7e
Lines 72 to 84 in b2c6c7e
Any ways to clean that up would be greatly appreciated! |
@damccorm it seems like we can't actually enable Azure Pipelines to run on Forks because of this little snippet I found in the docs:
That seems to indicate that "Make secrets available to builds of forks" is an all-or-nothing option. I'd either have to make the Coveralls token non-secret or expose our repo to attacks using it's security token. I really wish I could decide which secrets to allow to exposed forks. It'd also be really helpful if I could reject Azure Pipelines running if certain files were changed (like my package.json, etc) - it doesn't solve everything but it helps a lot. I'm going to close this for now and just concede that we need to run Travis, AppVeyor & Azure Pipelines side-by-side until Azure fits all our use cases better. |
@phated where are you pulling that from? It seems pretty misleading to me and I'd love to clean the doc up. To be clear, secrets are not scoped into tasks by default, regardless of whether secrets are enabled on forks. So unless you explicitly scope the security token into a task (which I definitely wouldn't recommend), forks will have no way of accessing that token. So if you have the following YAML definition:
task1 has access to Not sure if that changes how you view this or not, but just wanted to be clear on that. Several Microsoft repos enable secrets on forks, and that would be a big-time safety issue if people could attack the repos through that. |
@damccorm oh, that's good to know. I found those docs at https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/github?view=azure-devops#validate-contributions-from-forks For the time being, I just enabled the |
This will allow the token to be passed on PRs in without concern of it being stolen by a changed script. Without this, an attacker could change the
npm run coveralls
command in package.json in their PR so that it does something bad (e.g. sends them the token).See #2299 (comment)