Skip to content
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

Fixing AzureDevops title maxLength #2292

Merged
merged 4 commits into from
Feb 24, 2021
Merged
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 src/ReleaseHistory.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# SARIF Package Release History (SDK, Driver, Converters, and Multitool)

* FEATURE: `ConstructMultilineContextSnippet` will retrieve a few character after/before to prevent entire file when the file is one line only. [#2288](https://github.com/microsoft/sarif-sdk/pull/2288)
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • FEATURE: ConstructMultilineContextSnippet [](start = 0, length = 45)

Is this part of this particular pull request?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no...i was just adding missing release history stuff


In reply to: 581466908 [](ancestors = 581466908)

* BUGFIX: Fix AzureDevOps title maxLength. [#2292](https://github.com/microsoft/sarif-sdk/pull/2292)

## **v2.4.1** [Sdk](https://www.nuget.org/packages/Sarif.Sdk/2.4.1) | [Driver](https://www.nuget.org/packages/Sarif.Driver/2.4.1) | [Converters](https://www.nuget.org/packages/Sarif.Converters/2.4.1) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/2.4.1) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/2.4.1)
* BREAKING: Move `transform` functionality into `rewrite` and delete redundant `transform` command. [#2252](https://github.com/microsoft/sarif-sdk/pull/2252)
* FEATURE: kind, level, insert, and remove options can now be added to from environment variables. [#2273](https://github.com/microsoft/sarif-sdk/pull/2273)
Expand Down
10 changes: 5 additions & 5 deletions src/Sarif.WorkItems/SarifWorkItemsExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Microsoft.CodeAnalysis.Sarif.WorkItems
{
Expand All @@ -24,7 +24,7 @@ public static bool ShouldBeFiled(this Result result)
//
// Open: a sound analysis is 'open' indicating that the analysis requires
// more configuration or other data in order to produce a determination.
//
//
// Review: an open item which can't be automated, i.e., which requires a
// manual review to resolve.
return result.Kind == ResultKind.Fail ||
Expand All @@ -34,7 +34,7 @@ public static bool ShouldBeFiled(this Result result)
// Designations which are not appropriate for filing:
//
// Pass: the scan target explicitly passed analysis.
//
//
// Not applicable: analysis was skipped because it was not
// relevant to the scan target.
//
Expand Down Expand Up @@ -82,9 +82,9 @@ public static string CreateWorkItemTitle(this Run run)
firstResult.Level.ToString() + "]: " +
fullRuleId;

// In ADO, the title cannot be longer than 256 characters
// In ADO, the title cannot be longer than 255 characters
const string ellipsis = "...";
const int maxChars = 256;
const int maxChars = 255;
int remainingChars = maxChars - titlePrefix.Length - 6; // " ({0})".Length == 6

// We encapsulate logical names in apostrophes to help indicate they are a symbol
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Text;

using FluentAssertions;
Expand Down Expand Up @@ -60,7 +60,7 @@ public void SarifWorkItemExtensions_CreateWorkItemTitle_HandlesSingleResultWithR
[Fact]
public void SarifWorkItemExtensions_CreateWorkItemTitle_LongTitleFromUrl()
{
int maxLength = 256;
int maxLength = 255;
string ruleId = "TestRuleId";
string expectedTemplate = "[aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:Warning]: TestRuleId: Test Rule (in al...)";
string expected = $":Warning]: TestRuleId: Test Rule (in al" + new string('a', maxLength - expectedTemplate.Length) + "...)";
Expand Down Expand Up @@ -97,7 +97,7 @@ public void SarifWorkItemExtensions_CreateWorkItemTitle_LongTitleFromLogicalLoca
run.Results.Add(result);

// A logical location longer than 128 char is truncated with ellipses
int maxLength = 256;
int maxLength = 255;
string expectedTemplate = "[aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:Warning]: TestRuleId: Test Rule (in 'll...')";
string expected = $":Warning]: TestRuleId: Test Rule (in 'll" + new string('b', maxLength - expectedTemplate.Length) + "...')";
result.Locations[0].LogicalLocation.FullyQualifiedName = "ll" + new string('b', 1024);
Expand Down