Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Conversation

@ravimeda
Copy link
Member

@ravimeda ravimeda commented Aug 2, 2017

These changes allow automatic queuing of security build.

build/buildpipeline/security/Get-LatestVersion.ps1 is invoked by the root build (https://devdiv.visualstudio.com/DevDiv/_build/index?context=allDefinitions&path=%5CDotNet%5CSecurity&definitionId=6698&_a=completed) to retrieve commit SHA and package Id from latest.version. This info is passed onto the build leg i.e. DotNet-CLI-Security-Windows.json, which perform the scanning of assemblies and sources for security issues.

Refer (https://github.com/dotnet/core-eng/issues/1401).

Post merge, I will setup a trigger to run security build once per day, and cleanup documentation at https://github.com/dotnet/core-eng/blob/master/Documentation/Project-Docs/security-builds.md

@livarcocc PTAL.

Cc @MichaelSimons

@ravimeda ravimeda self-assigned this Aug 2, 2017
@ravimeda ravimeda requested a review from livarcocc August 2, 2017 21:20
@ravimeda
Copy link
Member Author

ravimeda commented Aug 2, 2017

@nguerrera since Livar is OOF, would you PTAL. This PR is a follow up of #7296
#Closed

"name": "DotNet-Cli-Trusted",
"url": "https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Cli-Trusted",
"defaultBranch": "refs/heads/master",
"defaultBranch": "refs/heads/sec_ext",

This comment was marked as spam.

This comment was marked as spam.

@ravimeda ravimeda requested a review from nguerrera August 3, 2017 14:58
@MichaelSimons
Copy link
Member

MichaelSimons commented Aug 3, 2017

@ravimeda, Does the Get-LatestVersion.ps1 script have to be invoked by the pipebuild definition or can it be invoked from the DotNet-CLI-Security-Windows build leg? It is generally a best practice to keep as much logic as possible out of the pipebuild definitions since they are not checked in. #Resolved

@ravimeda
Copy link
Member Author

ravimeda commented Aug 3, 2017

Good question, Michael. The way I was thinking is, the root build invokes Get-LatestVersion.ps1 once, and passes the info to build leg(s). One invocation and multiple uses.
But you have a valid point about having most of the logic in build legs i.e. the JSON file, which is versioned, and makes it easier to track changes. I agree. I'll update accordingly. #Closed


try
{
if(Test-Path "$latestVersionFilePath")

This comment was marked as spam.

This comment was marked as spam.

$latestVersionUrl = "$UrlPrefix/$Branch/$Filename"
$latestVersionFilePath = ".\latest.version"
$env:CliLatestCommitSha = ""
$env:CliLatestPackageId = ""

This comment was marked as spam.

This comment was marked as spam.

@ravimeda
Copy link
Member Author

ravimeda commented Aug 3, 2017

@MichaelSimons addressed the following through 0d837ca

  1. Get-LatestVersion is invoked in build leg
  2. CliLatestCommitSha and CliLatestPackageId are VSTS Task Variables and not environment variables
  3. Extracting the latest info from the web request response directly as opposed to downloading and reading the content.

PTAL.
#Closed

$retryCount = 1
$oldEap = $ErrorActionPreference

while ($retryCount -le 3)

This comment was marked as spam.

This comment was marked as spam.


try
{
return (Invoke-WebRequest -Uri "$latestVersionUrl" -UseBasicParsing).Content.Split([Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

$latestVersionUrl = "$UrlPrefix/$Branch/$Filename"
$latestVersionContent = Get-VersionInfo

if (-not [string]::IsNullOrWhiteSpace($latestVersionContent) -and $latestVersionContent.Length -eq 2)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

"inputs": {
"scriptType": "filePath",
"scriptName": "$(Build.SourcesDirectory)\\build\\buildpipeline\\security\\Get-LatestVersion.ps1",
"arguments": "-Branch \"$(CodeBase)\"",

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@ravimeda
Copy link
Member Author

ravimeda commented Aug 4, 2017

Addressed the following through d6bd18e

  1. Replaced 3 with $retries at line 30 of Get-LatestVersion.ps1
  2. In the same file, simplified the null check as if ($latestVersionContent -ne $null -and $latestVersionContent.Length -eq 2)
  3. Removed the value against workingFolder in the JSON.

PTAL

Thanks again.

Copy link
Member

@MichaelSimons MichaelSimons left a comment

Choose a reason for hiding this comment

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

LGTM

@ravimeda
Copy link
Member Author

ravimeda commented Aug 4, 2017

@nguerrera FYI I will merge as soon as the checks pass.

@ravimeda
Copy link
Member Author

ravimeda commented Aug 4, 2017

@nguerrera please could you merge this PR. The two failures appear unrelated to these changes.

@wli3
Copy link

wli3 commented Aug 4, 2017

@dotnet-bot test OpenSUSE42.1 x64 Debug Build
@dotnet-bot test Ubuntu16.10 x64 Debug Build

@wli3
Copy link

wli3 commented Aug 4, 2017

requeueing these tests, they should be healthy

@ravimeda ravimeda merged commit b60272d into dotnet:master Aug 4, 2017
@ravimeda
Copy link
Member Author

ravimeda commented Aug 4, 2017

Thanks all!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants