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

[BuildCheck Suggestion]: Flag Process.Start usages #10989

Open
JanKrivanek opened this issue Nov 18, 2024 · 3 comments
Open

[BuildCheck Suggestion]: Flag Process.Start usages #10989

JanKrivanek opened this issue Nov 18, 2024 · 3 comments
Labels
Area: BuildCheck BuildCheck Suggestion Suggestion for a built in MSBuild analyzer. Label should be applied together with 'Area: BuildCheck' triaged

Comments

@JanKrivanek
Copy link
Member

JanKrivanek commented Nov 18, 2024

Summary

Process.Start from within custom task should be flagged and usage of Exec or ToolTask tasks should be suggested.

On Hold (!)

Let's not action upon this yet. Let's first have a sample demonstrative case that'd be breaking the MSBuild server (plus see if it actually isn't already broken with the curent long lived nodes) and only then decide whether we want to restrict it.

Then we might possibly want to resort to compiler analyzer (or banned API) if runtime checks proves complicted

Background and Motivation

Process.Start creates child processes that cannot be easily controlled by MSBuild engine (as opposed to using Exec or ToolTask tasks). This can e.g. lead to issues during MSBuild server adoption (issue with redirecting outputs)

Notes

Possible ways to detect the Process.Start (need to be investigated if doable):

  • Injecting reroute function for Process.Start (akin unittest mocking)
  • .net profiling API
  • Monitor for child process creation (akin child process debugging)
@JanKrivanek JanKrivanek added Area: BuildCheck BuildCheck Suggestion Suggestion for a built in MSBuild analyzer. Label should be applied together with 'Area: BuildCheck' labels Nov 18, 2024
@KalleOlaviNiemitalo
Copy link

  • Scanning ECMA-355 metadata tables to detect if the task assembly references the Process.Start method
    • Con: could cause a false warning if the reference is in a method that is not called at run time.
  • DiagnosticSource notification from Process.Start
    • Con: needs changes in .NET Runtime.
  • Operating system features, e.g. JOB_OBJECT_MSG_NEW_PROCESS on Windows
    • Con: needs separate implementations for Windows, Linux, and macOS.
    • Con: needs extra logic to not warn about child processes started by a process that was started by Exec or ToolTask.

@baronfel
Copy link
Member

baronfel commented Nov 18, 2024

IMO v1 of this would be to rely on the BannedAPIAnalyzer, right? That seems like the lowest effort-to-reward ratio.

@rainersigwald
Copy link
Member

I don't understand what the concern is with Process.Start -- can you elaborate a bit more?

Detecting this at runtime seems basically impossible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: BuildCheck BuildCheck Suggestion Suggestion for a built in MSBuild analyzer. Label should be applied together with 'Area: BuildCheck' triaged
Projects
None yet
Development

No branches or pull requests

5 participants