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

Mime type validation #1206

Merged
merged 2 commits into from
Jan 12, 2019
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
1 change: 0 additions & 1 deletion src/Sarif.Converters.UnitTests/ConverterTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using FluentAssertions;

using Microsoft.CodeAnalysis.Sarif.Converters;
using Microsoft.CodeAnalysis.Sarif.Readers;
using Microsoft.CodeAnalysis.Sarif.TestUtilities;
using Newtonsoft.Json;

Expand Down
1 change: 0 additions & 1 deletion src/Sarif.Converters.UnitTests/FortifyFprConverterTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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 Xunit;
using Xunit.Abstractions;

Expand Down
2 changes: 0 additions & 2 deletions src/Sarif.Converters/SemmleQlConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using CsvHelper;
using Microsoft.CodeAnalysis.Sarif.Visitors;

namespace Microsoft.CodeAnalysis.Sarif.Converters
{
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.Converters/ToolFileConverterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis.Sarif.Visitors;
using Microsoft.CodeAnalysis.Sarif.Writers;

Expand Down
1 change: 0 additions & 1 deletion src/Sarif.Driver.UnitTests/Sdk/AnalyzeCommandBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Reflection;
using FluentAssertions;
using Microsoft.CodeAnalysis.Sarif.Readers;
using Microsoft.CodeAnalysis.Sarif.VersionOne;
using Newtonsoft.Json;
using Xunit;

Expand Down
2 changes: 0 additions & 2 deletions src/Sarif.Driver.UnitTests/TestRuleBase.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// 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 Microsoft.CodeAnalysis.Sarif.Readers;

namespace Microsoft.CodeAnalysis.Sarif.Driver
{
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.Driver/Sdk/AnalyzeCommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.Driver/Sdk/AnalyzeOptionsBase.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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 CommandLine;
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.Driver/Sdk/ExportRulesMetadataCommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Collections.Immutable;
using System.IO;
using System.Text;
using Microsoft.CodeAnalysis.Sarif.Readers;

using Newtonsoft.Json;

Expand Down
1 change: 0 additions & 1 deletion src/Sarif.Driver/Sdk/MultifileOptionsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Collections.Generic;
using CommandLine;
using Microsoft.CodeAnalysis.Sarif.Driver;

namespace Microsoft.CodeAnalysis.Sarif.Driver
{
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.Driver/Sdk/SingleFileOptionsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using CommandLine;
using Microsoft.CodeAnalysis.Sarif.Driver;

namespace Microsoft.CodeAnalysis.Sarif.Driver
{
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.FunctionalTests/PropertyBagConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using FluentAssertions;
using Microsoft.CodeAnalysis.Sarif.Readers;
using Microsoft.CodeAnalysis.Sarif.TestUtilities;
using Newtonsoft.Json;
using Xunit;
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.FunctionalTests/SarifConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Text;

using FluentAssertions;
using Microsoft.CodeAnalysis.Sarif.Readers;
using Microsoft.CodeAnalysis.Sarif.Visitors;
using Microsoft.CodeAnalysis.Sarif.Writers;
using Newtonsoft.Json;
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.FunctionalTests/SarifLogEqualityComparerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.IO;
using FluentAssertions;
using Microsoft.CodeAnalysis.Sarif.Readers;
using Microsoft.CodeAnalysis.Sarif.TestUtilities;
using Microsoft.CodeAnalysis.Sarif.Writers;
using Newtonsoft.Json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.CodeAnalysis.Sarif.Writers;
using System;
using System.IO;
using System.Xml;
using Xunit;

namespace Microsoft.CodeAnalysis.Sarif.Multitool
Expand Down
9 changes: 0 additions & 9 deletions src/Sarif.Multitool.UnitTests/TransformCommandTests.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
// 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.IO;
using FluentAssertions;
using Microsoft.CodeAnalysis.Sarif;
using Microsoft.CodeAnalysis.Sarif.Multitool;
using Microsoft.CodeAnalysis.Sarif.Readers;
using Microsoft.CodeAnalysis.Sarif.VersionOne;
using Moq;
using Newtonsoft.Json;
using Xunit;

namespace Sarif.Multitool.UnitTests
{
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.Multitool/RewriteCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis.Sarif.Visitors;
using Microsoft.CodeAnalysis.Sarif.Driver.Sdk;
using Newtonsoft.Json;
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.Multitool/Rules/UrisMustBeValid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.Json.Pointer;

namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.UnitTests/Core/FileLocationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Text;
using FluentAssertions;
using Xunit;
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.UnitTests/Core/PropertyBagHolderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using FluentAssertions;
using Microsoft.CodeAnalysis.Sarif.Readers;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Xunit;
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.UnitTests/Core/SarifLogTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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 FluentAssertions;
using Newtonsoft.Json;
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.UnitTests/Core/TagsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Collections.Generic;
using FluentAssertions;
using Microsoft.CodeAnalysis.Sarif.Readers;
using Xunit;

namespace Microsoft.CodeAnalysis.Sarif
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.UnitTests/JsonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.IO;
using System.Text;
using Microsoft.CodeAnalysis.Sarif.Readers;
using Microsoft.CodeAnalysis.Sarif.Writers;
using Newtonsoft.Json;

Expand Down
4 changes: 0 additions & 4 deletions src/Sarif.UnitTests/MockFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using FluentAssertions;
using Moq;

using Match = System.Text.RegularExpressions.Match; // Avoid ambiguity with Moq.Match;

namespace Microsoft.CodeAnalysis.Sarif
{
internal static class MockFactory
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.UnitTests/Processors/Log/RebaseUriStageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Microsoft.CodeAnalysis.Sarif.Visitors;
using Xunit;
using Xunit.Abstractions;

Expand Down
1 change: 0 additions & 1 deletion src/Sarif.UnitTests/Readers/SampleModel/LogModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Xunit;

namespace Microsoft.CodeAnalysis.Sarif.Readers.SampleModel
{
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.UnitTests/Visitors/MakeUriAbsoluteVisitorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Microsoft.CodeAnalysis.Sarif.Readers;
using Xunit;

namespace Microsoft.CodeAnalysis.Sarif.Visitors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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 Microsoft.CodeAnalysis.Sarif.Writers;
using Newtonsoft.Json;
using Xunit;
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.UnitTests/Visitors/RebaseUriVisitorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.IO;
using System.Linq;
using FluentAssertions;
using Microsoft.CodeAnalysis.Sarif.Readers;
using Microsoft.CodeAnalysis.Sarif.Writers;
using Newtonsoft.Json;
using Xunit;
Expand Down
4 changes: 2 additions & 2 deletions src/Sarif.ValidationTests/DefaultObjectPopulatingVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static IDictionary<Type, PrimitiveValueBuilder> GetBuildersForRequiredPri
{ typeof(bool), (isRequired) => { return isRequired; } },
{ typeof(int), (isRequired) => { return isRequired ? int.MaxValue : 0; } },
{ typeof(double), (isRequired) => { return isRequired ? double.MaxValue : 0; } },
{ typeof(string), (isRequired) => { return isRequired ? "Required string value." : null; } },
{ typeof(string), (isRequired) => { return isRequired ? "string/required" : null; } },
{ typeof(DateTime),(isRequired) => { return isRequired ? DateTime.UtcNow : new DateTime(); } },
{ typeof(Uri), (isRequired) => { return isRequired ? new Uri("https://required.uri.contoso.com") : null; } }
};
Expand All @@ -45,7 +45,7 @@ public static IDictionary<Type, PrimitiveValueBuilder> GetBuildersForAllPrimitiv
{ typeof(bool), (isRequired) => { return true; } },
{ typeof(int), (isRequired) => { return isRequired ? int.MaxValue : 1; } },
{ typeof(double), (isRequired) => { return isRequired ? double.MaxValue : 1; } },
{ typeof(string), (isRequired) => { return isRequired ? "[Required string value]" : "[Optional string value]"; } },
{ typeof(string), (isRequired) => { return isRequired ? "string/required" : "string/optional"; } },
{ typeof(DateTime),(isRequired) => { return isRequired ? new DateTime(2018, 10, 31).ToUniversalTime() : new DateTime(1776, 7, 4).ToUniversalTime(); } },
{ typeof(Uri), (isRequired) => { return isRequired ? new Uri("https://required.uri.value.contoso.com") : new Uri("https://optional.uri.value.contoso.com"); } }
};
Expand Down
1 change: 0 additions & 1 deletion src/Sarif.ValidationTests/SarifValidatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Microsoft.Json.Schema;
using Microsoft.Json.Schema.Validation;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Xunit;

namespace Microsoft.CodeAnalysis.Sarif
Expand Down
30 changes: 16 additions & 14 deletions src/Sarif/Autogenerated/FileData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
using Microsoft.CodeAnalysis.Sarif.Readers;
using Newtonsoft.Json;
Expand All @@ -14,7 +15,7 @@ namespace Microsoft.CodeAnalysis.Sarif
/// A single file. In some cases, this file might be nested within another file.
/// </summary>
[DataContract]
[GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.58.0.0")]
[GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.61.0.0")]
public partial class FileData : PropertyBagHolder, ISarifNode
{
public static IEqualityComparer<FileData> ValueComparer => FileDataEqualityComparer.Instance;
Expand Down Expand Up @@ -43,8 +44,8 @@ public SarifNodeKind SarifNodeKind
/// Identifies the index of the immediate parent of the file, if this file is nested.
/// </summary>
[DataMember(Name = "parentIndex", IsRequired = false, EmitDefaultValue = false)]
[DefaultValue(-1)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
[System.ComponentModel.DefaultValue(-1)]
public int ParentIndex { get; set; }

/// <summary>
Expand All @@ -63,6 +64,7 @@ public SarifNodeKind SarifNodeKind
/// The role or roles played by the file in the analysis.
/// </summary>
[DataMember(Name = "roles", IsRequired = false, EmitDefaultValue = false)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
[JsonConverter(typeof(FlagsEnumConverter))]
public FileRoles Roles { get; set; }

Expand Down Expand Up @@ -94,7 +96,7 @@ public SarifNodeKind SarifNodeKind
/// The Coordinated Universal Time (UTC) date and time at which the file was most recently modified. See "Date/time properties" in the SARIF spec for the required format.
/// </summary>
[DataMember(Name = "lastModifiedTimeUtc", IsRequired = false, EmitDefaultValue = false)]
[JsonConverter(typeof(DateTimeConverter))]
[JsonConverter(typeof(Microsoft.CodeAnalysis.Sarif.Readers.DateTimeConverter))]
public DateTime LastModifiedTimeUtc { get; set; }

/// <summary>
Expand All @@ -115,37 +117,37 @@ public FileData()
/// Initializes a new instance of the <see cref="FileData" /> class from the supplied values.
/// </summary>
/// <param name="fileLocation">
/// An initialization value for the <see cref="P: FileLocation" /> property.
/// An initialization value for the <see cref="P:FileLocation" /> property.
/// </param>
/// <param name="parentIndex">
/// An initialization value for the <see cref="P: ParentIndex" /> property.
/// An initialization value for the <see cref="P:ParentIndex" /> property.
/// </param>
/// <param name="offset">
/// An initialization value for the <see cref="P: Offset" /> property.
/// An initialization value for the <see cref="P:Offset" /> property.
/// </param>
/// <param name="length">
/// An initialization value for the <see cref="P: Length" /> property.
/// An initialization value for the <see cref="P:Length" /> property.
/// </param>
/// <param name="roles">
/// An initialization value for the <see cref="P: Roles" /> property.
/// An initialization value for the <see cref="P:Roles" /> property.
/// </param>
/// <param name="mimeType">
/// An initialization value for the <see cref="P: MimeType" /> property.
/// An initialization value for the <see cref="P:MimeType" /> property.
/// </param>
/// <param name="contents">
/// An initialization value for the <see cref="P: Contents" /> property.
/// An initialization value for the <see cref="P:Contents" /> property.
/// </param>
/// <param name="encoding">
/// An initialization value for the <see cref="P: Encoding" /> property.
/// An initialization value for the <see cref="P:Encoding" /> property.
/// </param>
/// <param name="hashes">
/// An initialization value for the <see cref="P: Hashes" /> property.
/// An initialization value for the <see cref="P:Hashes" /> property.
/// </param>
/// <param name="lastModifiedTimeUtc">
/// An initialization value for the <see cref="P: LastModifiedTimeUtc" /> property.
/// An initialization value for the <see cref="P:LastModifiedTimeUtc" /> property.
/// </param>
/// <param name="properties">
/// An initialization value for the <see cref="P: Properties" /> property.
/// An initialization value for the <see cref="P:Properties" /> property.
/// </param>
public FileData(FileLocation fileLocation, int parentIndex, int offset, int length, FileRoles roles, string mimeType, FileContent contents, string encoding, IDictionary<string, string> hashes, DateTime lastModifiedTimeUtc, IDictionary<string, SerializedPropertyInfo> properties)
{
Expand Down
Loading