我有一个 powershell 脚本,可以找出 npm 依赖项中的漏洞。我正在收到一份报告,我在某些部分也使用了 ConvertTo-Html,但我想使用 html 和 css 来增加相同的可读性并创建一个适当的报告。我试图解析输出并从中创建一个 HTML,但无法使用正确的格式。我对它有点陌生,所以需要一些帮助。
下面是脚本中的一个函数。
if($input1.EndsWith("package.json"))
{
$json = Get-Content $input1 -raw | ConvertFrom-Json | ConvertTo-Html | Out-File ./report.html
$obj = $json.dependencies
$json.dependencies | Get-Member -MemberType NoteProperty | ForEach-Object | ConvertTo-Html | Out-File ./out.html{
$key = $_.Name
$values = [PSCustomObject][ordered]@{Key = $key; Value = $obj."$key"}
$k = $values.Value
$k1 = $values.key