Skip to content

Security scan #6

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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,6 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/

# SonarQube
.sonarqube/
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO;
using System.Linq.Expressions;
using System.Threading.Tasks;
using System.Threading.Tasks;
using NUnit.Framework;
using TailSpin.SpaceGame.Web;
using TailSpin.SpaceGame.Web.Models;

using TailSpin.SpaceGame.Web.Models;
namespace Tests
{
public class DocumentDBRepository_GetItemsAsyncShould
Expand All @@ -18,9 +18,9 @@ public void Setup()
{
using (Stream scoresData = typeof(IDocumentDBRepository<Score>)
.Assembly
.GetManifestResourceStream("Tailspin.SpaceGame.Web.SampleData.scores.json"))
{
_scoreRepository = new LocalDocumentDBRepository<Score>(scoresData);
.GetManifestResourceStream("Tailspin.SpaceGame.Web.SampleData.scores.json"))
{
_scoreRepository = new LocalDocumentDBRepository<Score>(scoresData);
}
}

Expand All @@ -33,16 +33,16 @@ public void FetchOnlyRequestedGameRegion(string gameRegion)
{
const int PAGE = 0; // take the first page of results
const int MAX_RESULTS = 10; // sample up to 10 results

// Form the query predicate.
// This expression selects all scores for the provided game region.
Expression<Func<Score, bool>> queryPredicate = score => (score.GameRegion == gameRegion);

// Fetch the scores.
Task<IEnumerable<Score>> scoresTask = _scoreRepository.GetItemsAsync(
queryPredicate, // the predicate defined above
score => 1, // we don't care about the order
PAGE,
// Form the query predicate.
// This expression selects all scores for the provided game region.
Expression<Func<Score, bool>> queryPredicate = score => (score.GameRegion == gameRegion);
// Fetch the scores.
Task<IEnumerable<Score>> scoresTask = _scoreRepository.GetItemsAsync(
queryPredicate, // the predicate defined above
score => 1, // we don't care about the order
PAGE,
MAX_RESULTS
);
IEnumerable<Score> scores = scoresTask.Result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.6.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="nunit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
Expand Down
64 changes: 64 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,77 @@ steps:
command: 'restore'
projects: '**/*.csproj'

- task: SonarCloudPrepare@1
displayName: 'Prepare SonarCloud analysis'
inputs:
SonarCloud: 'SonarCloud connection 1'
organization: '$(organization)'
projectKey: '$(projectKey)'
projectName: '$(projectName)'
projectVersion: '$(Build.BuildNumber)'
extraProperties: |
sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/TestResults/Coverage/coverage.opencover.xml
sonar.exclusions=**/wwwroot/lib/**/*
condition: |
and
(
succeeded(),
eq(variables['Build.Reason'], 'PullRequest'),
eq(variables['System.PullRequest.TargetBranch'], 'master')
)

- task: DotNetCoreCLI@2
displayName: 'Build the project - $(buildConfiguration)'
inputs:
command: 'build'
arguments: '--no-restore --configuration $(buildConfiguration)'
projects: '**/*.csproj'

- task: DotNetCoreCLI@2
displayName: 'Install ReportGenerator'
inputs:
command: custom
custom: tool
arguments: 'install --global dotnet-reportgenerator-globaltool'

- task: DotNetCoreCLI@2
displayName: 'Run unit tests - $(buildConfiguration)'
inputs:
command: 'test'
arguments: '--no-build --configuration $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat="cobertura%2copencover" /p:CoverletOutput=$(Build.SourcesDirectory)/TestResults/Coverage/'
publishTestResults: true
projects: '**/*.Tests.csproj'

- script: |
reportgenerator -reports:$(Build.SourcesDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage -reporttypes:HtmlInline_AzurePipelines
displayName: 'Create code coverage report'

- task: SonarCloudAnalyze@1
displayName: 'Run SonarCloud code analysis'
condition: |
and
(
succeeded(),
eq(variables['Build.Reason'], 'PullRequest'),
eq(variables['System.PullRequest.TargetBranch'], 'master')
)

- task: SonarCloudPublish@1
displayName: 'Publish SonarCloud quality gate results'
condition: |
and
(
succeeded(),
eq(variables['Build.Reason'], 'PullRequest'),
eq(variables['System.PullRequest.TargetBranch'], 'master')
)

- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage report'
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(Build.SourcesDirectory)/**/coverage.cobertura.xml'

- task: DotNetCoreCLI@2
displayName: 'Publish the project - $(buildConfiguration)'
inputs:
Expand Down
73 changes: 30 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"gulp-cssmin": "0.2.0",
"gulp-uglify": "3.0.0",
"rimraf": "2.6.1",
"node-sass": "4.11.0"
"node-sass": "4.12.0"
}
}