8000 NVSHAS-9791: read runtime dependency not dev dependency by pohanhuangtw · Pull Request #1960 · neuvector/neuvector · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

NVSHAS-9791: read runtime dependency not dev dependency #1960

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

Merged
merged 3 commits into from
May 13, 2025

Conversation

pohanhuangtw
Copy link
Contributor
@pohanhuangtw pohanhuangtw commented May 7, 2025

Summary

  • In .NET applications, multiple *.deps.json files may exist, but only the runtime dependencies are relevant for identifying actual vulnerabilities — not the development-time dependencies.
    • Currently, NV including all dependencies by default, regardless of whether they’re actually used at runtime.
    • Incorporating the runtime section into our logic would make this more accurate.
  • add os.Getenv("SCAN_DOTNET_RUNTIME") to ensure backward compatible
    Here are some .deps.json snippets for context:
"Microsoft.AspNetCore.Authentication.OpenIdConnect/7.0.0": {
  "dependencies": {
    "Microsoft.IdentityModel.Protocols.OpenIdConnect": "6.15.1"
  },
  "runtime": {
    "lib/net7.0/Microsoft.AspNetCore.Authentication.OpenIdConnect.dll": {
      "assemblyVersion": "7.0.0.0",
      "fileVersion": "7.0.22.51819"
    }
  }
},
"Microsoft.AspNetCore.Http/2.2.2": {
  "dependencies": {
    "Microsoft.AspNetCore.Http.Abstractions": "2.2.0",
    "Microsoft.AspNetCore.WebUtilities": "2.2.0",
    "Microsoft.Extensions.ObjectPool": "2.2.0",
    "Microsoft.Extensions.Options": "8.0.2",
    "Microsoft.Net.Http.Headers": "2.2.0"
  }
},
"Microsoft.AspNetCore.Http.Abstractions/2.2.0": {
  "dependencies": {
    "Microsoft.AspNetCore.Http.Features": "2.2.0",
    "System.Text.Encodings.Web": "4.5.0"
  }
}

8000
Signed-off-by: pohanhuangtw <pohan.huang@suse.com>
@pohanhuangtw pohanhuangtw requested review from a team as code owners May 7, 2025 13:28
@pohanhuangtw pohanhuangtw requested a review from jayhuang-suse May 7, 2025 13:28
Copy link
Contributor
@jayhuang-suse jayhuang-suse left a comment

Choose a reason for hiding this comment

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

Can you provide an online link to differ its runtime dependency from other dependencies?

@pohanhuangtw
Copy link
Contributor Author
pohanhuangtw commented May 7, 2025

Hi @jayhuang-suse ,
Thanks for the review.
Actually, I haven’t found an official way to distinguish runtime dependencies from development ones through a direct link or online tool.

However, when I inspect the .deps.json files using grep, I notice a pattern like this:

./<hash>/usr/share/dotnet/shared/Microsoft.AspNetCore.App/8.0.11/Microsoft.AspNetCore.App.deps.json  
./<hash>/app/Swimlane.SecurityIntelligence.deps.json  
./<hash>/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.11/Microsoft.NETCore.App.deps.json  
Based on this, I assume the files under usr/share/dotnet/shared/ are runtime framework dependencies provided by the .NET runtime, while the one under /app/ is specific to the application and includes both runtime and compile-time dependencies.

@pohanhuangtw pohanhuangtw changed the title fix: read runtime dependency not dev dependency NVSHAS-9791: read runtime dependency not dev dependency May 7, 2025
@pohanhuangtw
Copy link
Contributor Author

Hi @jayhuang-suse,

TL;DR:
I propose to only consider dependencies that have a corresponding runtime entry.
If a dependency doesn't include a runtime section, we’ll ignore it.

Here are some .deps.json snippets for context:

"Microsoft.AspNetCore.Authentication.OpenIdConnect/7.0.0": {
  "dependencies": {
    "Microsoft.IdentityModel.Protocols.OpenIdConnect": "6.15.1"
  },
  "runtime": {
    "lib/net7.0/Microsoft.AspNetCore.Authentication.OpenIdConnect.dll": {
      "assemblyVersion": "7.0.0.0",
      "fileVersion": "7.0.22.51819"
    }
  }
},
"Microsoft.AspNetCore.Http/2.2.2": {
  "dependencies": {
    "Microsoft.AspNetCore.Http.Abstractions": "2.2.0",
    "Microsoft.AspNetCore.WebUtilities": "2.2.0",
    "Microsoft.Extensions.ObjectPool": "2.2.0",
    "Microsoft.Extensions.Options": "8.0.2",
    "Microsoft.Net.Http.Headers": "2.2.0"
  }
},
"Microsoft.AspNetCore.Http.Abstractions/2.2.0": {
  "dependencies": {
    "Microsoft.AspNetCore.Http.Features": "2.2.0",
    "System.Text.Encodings.Web": "4.5.0"
  }
}

Currently, we’re including all dependencies by default, regardless of whether they’re actually used at runtime.
Incorporating the runtime section into our logic would make this more accurate.
It would help us focus on what’s truly executed, avoid false positives, and skip compile-time or transitive dependencies that don’t end up in the final application.

Let me know if you foresee any concerns with this approach.

cc: @holyspectral

@pohanhuangtw pohanhuangtw force-pushed the NVSHAS-9791 branch 2 times, most recently from f8595d2 to e2ec028 Compare May 8, 2025 02:55
Signed-off-by: pohanhuangtw <pohan.huang@suse.com>
@jayhuang-suse
Copy link
Contributor

The test scanner image will manually be tested against nightly tests. Let hear the feedbacks of the results. It is about the dotNet packages and expect some dropped cases and please give an example why those missing CVEs are false-positive cases.

@pohanhuangtw
Copy link
Contributor Author

Hi @jayhuang-suse , @holyspectral
This has been test by QA, I think we can merge it.

… if SCAN_DOTNET_RUNTIME is set

Signed-off-by: pohanhuangtw <pohan.huang@suse.com>
@jayhuang-suse
Copy link
Contributor

I understand this package shared by enforcer and scanner but I am not sure that our code standard can accept taking any environment variable in a normal function call. @holyspectral

"os.Getenv("SCAN_DOTNET_RUNTIME")"

@holyspectral
Copy link
Collaborator

@jayhuang-suse sorry I don't really get what you mean. Can you elaborate more?

@jayhuang-suse
Copy link
Contributor

Do we allow use the "os.Getenv()" in a normal function call?

We usually use the "monitor" app to parse the ENV, then carry them down with the parameter flags into "main()". This PR will use this ENV directly to control the detection in a not-main() entry.... Do you have any code-standard or security concerns?

@holyspectral
Copy link
Collaborator

@jayhuang-suse that's a good question. In terms of security, an environment variable is actually better than a command line parameter because you need extra permission to access its environment variables. That's why generally command line parameters should be avoided. Having said that, for an on/off switch I think both are acceptable.

I don't think NeuVector has a strict guideline about which to use at the moment. It's worth noting that helm charts doesn't support overriding command line parameters, so it's fine with me if we want to use an environment variable instead, especially for a non user-facing configuration.

@pohanhuangtw pohanhuangtw merged commit cb1dc6c into neuvector:main May 13, 2025
6 checks passed
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.

3 participants
0