mirror of
https://dev.azure.com/effectory/Survey%20Software/_git/Cloud%20Engineering
synced 2026-02-27 18:52:18 +01:00
Merged PR 52474: Created devops pull request list and SBOM based on SNYK dependencies download...
Created devops pull request list and SBOM based on SNYK dependencies downloads #86990 Related work items: #86990
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Powershell/Tools/temp.ps1
|
||||||
55
Powershell/Lists/DevOps/PullRequests.ps1
Normal file
55
Powershell/Lists/DevOps/PullRequests.ps1
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
|
||||||
|
class PullRequest {
|
||||||
|
[string] $RepositoryId = ""
|
||||||
|
[string] $RepositoryName = ""
|
||||||
|
[string] $DefaultBranch = ""
|
||||||
|
[string] $RepositoryWebUrl = ""
|
||||||
|
[string] $PullRequestId = ""
|
||||||
|
[string] $PullRequestDate = ""
|
||||||
|
[string] $PullRequestName = ""
|
||||||
|
[string] $PullRequestCreatedBy = ""
|
||||||
|
[string] $PullRequestReviewers = ""
|
||||||
|
[string] $PullRequestStatus = ""
|
||||||
|
[string] $PullRequestWebUrl = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
[string] $date = Get-Date -Format "yyyy-MM-dd HHmm"
|
||||||
|
$fileName = ".\$date pull requests.csv"
|
||||||
|
|
||||||
|
Write-Host "========================================================================================================================================================================"
|
||||||
|
Write-Host "Creating repository overview."
|
||||||
|
Write-Host "========================================================================================================================================================================"
|
||||||
|
|
||||||
|
$repos = az repos list --organization "https://dev.azure.com/effectory/" --project "survey software" | ConvertFrom-Json | Select-Object | Where-Object { $true -ne $_.isDisabled }
|
||||||
|
|
||||||
|
foreach ($repo in $repos)
|
||||||
|
{
|
||||||
|
$prs = az repos pr list --project "survey software" --repository "$($repo.name)" --organization "https://dev.azure.com/effectory/" --status all | ConvertFrom-Json | Select-Object
|
||||||
|
|
||||||
|
[PullRequest[]]$Result = @()
|
||||||
|
|
||||||
|
foreach ($pr in $prs)
|
||||||
|
{
|
||||||
|
[PullRequest] $pullRequest = [PullRequest]::new()
|
||||||
|
$pullRequest.RepositoryId = $repo.id
|
||||||
|
$pullRequest.RepositoryName = $repo.name
|
||||||
|
$pullRequest.DefaultBranch = $repo.defaultBranch
|
||||||
|
$pullRequest.RepositoryWebUrl = $repo.webUrl
|
||||||
|
$pullRequest.PullRequestId = $pr.pullRequestId
|
||||||
|
$pullRequest.PullRequestDate = $pr.creationDate
|
||||||
|
$pullRequest.PullRequestName = $pr.title
|
||||||
|
$pullRequest.PullRequestCreatedBy = $pr.createdBy.displayName
|
||||||
|
$pullRequest.PullRequestReviewers = $pr.reviewers | join-string -property displayName -Separator ','
|
||||||
|
$pullRequest.PullRequestStatus = $pr.status
|
||||||
|
$pullRequest.PullRequestWebUrl = "$($repo.webUrl)/pullrequest/$($pr.pullRequestId)"
|
||||||
|
$Result += $pullRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
$Result | Export-Csv -Path $fileName -Append -NoTypeInformation
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-Host "========================================================================================================================================================================"
|
||||||
|
Write-Host "Done."
|
||||||
|
|
||||||
137
Powershell/Lists/Snyk/SBOM.ps1
Normal file
137
Powershell/Lists/Snyk/SBOM.ps1
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
Write-Host "================================================================================================="
|
||||||
|
Write-Host "Creating Software Bill Of Materials."
|
||||||
|
Write-Host "================================================================================================="
|
||||||
|
|
||||||
|
class CSVItem {
|
||||||
|
[string] $FileName = ""
|
||||||
|
[string] $id = ""
|
||||||
|
[string] $name = ""
|
||||||
|
[string] $version = ""
|
||||||
|
[string] $type = ""
|
||||||
|
[string] $issuesCritical = ""
|
||||||
|
[string] $issuesHigh = ""
|
||||||
|
[string] $issuesMedium = ""
|
||||||
|
[string] $issuesLow = ""
|
||||||
|
[string] $dependenciesWithIssues = ""
|
||||||
|
[string] $licenses = ""
|
||||||
|
[string] $projects = ""
|
||||||
|
[string] $license_urls = ""
|
||||||
|
[string] $latestVersion = ""
|
||||||
|
[string] $latestVersionUrl = ""
|
||||||
|
[string] $latestVersionPublishedDate = ""
|
||||||
|
[string] $firstPublishedDate = ""
|
||||||
|
[string] $versionUrl = ""
|
||||||
|
[string] $isDeprecated = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
function PropagatePackage {
|
||||||
|
|
||||||
|
param (
|
||||||
|
[CSVItem[]] $allItems,
|
||||||
|
[string] $name,
|
||||||
|
[string] $version,
|
||||||
|
[string] $type,
|
||||||
|
[string] $progress
|
||||||
|
)
|
||||||
|
|
||||||
|
$foundItems = $allItems | Where-Object { ($_.name -eq $name) -and ($_.version -eq $version) -and ($_.type -eq $type)}
|
||||||
|
|
||||||
|
write-Host "[$progress] - Find $type package info for $name ($version) [$($foundItems.Length)]"
|
||||||
|
|
||||||
|
if ($type -ne "nuget") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
$nuget = Find-Package $name -RequiredVersion $version -ProviderName Nuget
|
||||||
|
|
||||||
|
if ($null -eq $nuget) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$lastNuget = Find-Package $name -ProviderName Nuget
|
||||||
|
}
|
||||||
|
catch {}
|
||||||
|
|
||||||
|
foreach ($propagateItem in $foundItems) {
|
||||||
|
$propagateItem.firstPublishedDate = $nuget.metadata["published"]
|
||||||
|
$propagateItem.versionUrl = "https://www.nuget.org/packages/$name/$version"
|
||||||
|
if ($null -ne $lastNuget) {
|
||||||
|
$propagateItem.latestVersion = $lastNuget.Version;
|
||||||
|
$propagateItem.latestVersionPublishedDate = $lastNuget.metadata["published"]
|
||||||
|
$propagateItem.latestVersionUrl = "https://www.nuget.org/packages/$name/$($lastNuget.Version)"
|
||||||
|
}
|
||||||
|
$propagateItem.isDeprecated = ($null -eq $lastNuget) -or ($nuget.metadata["summary"] -like "*Deprecated*") -or ($nuget.metadata["title"] -like "*Deprecated*") -or ($nuget.metadata["tags"] -like "*Deprecated*")-or ($nuget.metadata["description"] -like "*Deprecated*")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
[string] $date = Get-Date -Format "yyyy-MM-dd HHmm"
|
||||||
|
$fileName = ".\$date snyk_npm_nuget_sbom.csv"
|
||||||
|
|
||||||
|
Write-Host "-------------------------------------------------------------------------------------------------"
|
||||||
|
Write-Host "Parsing CSV Files.."
|
||||||
|
Write-Host "-------------------------------------------------------------------------------------------------"
|
||||||
|
|
||||||
|
$csvDependenciesExportPath = "c:\temp\snyk\*.csv"
|
||||||
|
|
||||||
|
$files = Get-ChildItem $csvDependenciesExportPath
|
||||||
|
|
||||||
|
[CSVItem[]]$CSVItems = @()
|
||||||
|
|
||||||
|
foreach($file in $files) {
|
||||||
|
Write-Host $file.FullName
|
||||||
|
|
||||||
|
$csv = Import-Csv -Path $file.FullName
|
||||||
|
|
||||||
|
foreach ($csvLine in $csv) {
|
||||||
|
[CSVItem] $CSVItem = [CSVItem]::new()
|
||||||
|
$CSVItem.FileName = $file.Name
|
||||||
|
|
||||||
|
$CSVItem.id = $csvLine.id
|
||||||
|
$CSVItem.name = $csvLine.name
|
||||||
|
$CSVItem.version = $csvLine.version
|
||||||
|
$CSVItem.type = $csvLine.type
|
||||||
|
$CSVItem.issuesCritical = $csvLine.issuesCritical
|
||||||
|
$CSVItem.issuesHigh = $csvLine.issuesHigh
|
||||||
|
$CSVItem.issuesMedium = $csvLine.issuesMedium
|
||||||
|
$CSVItem.issuesLow = $csvLine.issuesLow
|
||||||
|
$CSVItem.dependenciesWithIssues = $csvLine.dependenciesWithIssues
|
||||||
|
$CSVItem.licenses = $csvLine.licenses
|
||||||
|
$CSVItem.projects = $csvLine.projects
|
||||||
|
$CSVItem.license_urls = $csvLine."license urls"
|
||||||
|
$CSVItem.latestVersion = $csvLine.latestVersion
|
||||||
|
$CSVItem.latestVersionPublishedDate = $csvLine.latestVersionPublishedDate
|
||||||
|
$CSVItem.firstPublishedDate = $csvLine.firstPublishedDate
|
||||||
|
$CSVItem.isDeprecated = $csvLine.isDeprecated
|
||||||
|
|
||||||
|
$CSVItems += $CSVItem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "-------------------------------------------------------------------------------------------------"
|
||||||
|
Write-Host "Determine objects.."
|
||||||
|
Write-Host "-------------------------------------------------------------------------------------------------"
|
||||||
|
|
||||||
|
$toDo = $CSVItems | Where-Object { $_.type -eq "nuget" } | Sort-Object -Property version| Sort-Object -Property name
|
||||||
|
$counter = 0
|
||||||
|
$length = $toDo.Length
|
||||||
|
foreach ($package in $toDo) {
|
||||||
|
$counter = $counter + 1
|
||||||
|
|
||||||
|
if ($package.latestVersion -eq "") {
|
||||||
|
PropagatePackage -allItems $CSVItems -name $package.name -type $package.type -version $package.version -progress ("{0:D4}/{1:D4}" -f $counter, $length)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "-------------------------------------------------------------------------------------------------"
|
||||||
|
Write-Host "Saving overview.."
|
||||||
|
Write-Host "-------------------------------------------------------------------------------------------------"
|
||||||
|
|
||||||
|
$CSVItems | Export-Csv -Path $fileName -NoTypeInformation
|
||||||
|
|
||||||
|
Write-Host "Done."
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user