Skip to content

Whitelist #73

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

Merged
merged 13 commits into from
Nov 3, 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Thumbs.db
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
*/packages/*/
**/.vs/*
**/packages/*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>1.1.0</Version>
<Version>2.1.3</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Coderr.Server.Api.Client.xml</DocumentationFile>
<RootNamespace>Coderr.Server.Api.Client</RootNamespace>
<AssemblyName>Coderr.Server.Api.Client</AssemblyName>
</PropertyGroup>
<PropertyGroup>
<PackageId>Coderr.Server.Api.Client</PackageId>
<Authors>1TCompany AB</Authors>
<Description>API client for codeRR Server.</Description>
<Description>API client for Coderr Server.</Description>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>Converted to vstudio 2017 csproj format</PackageReleaseNotes>
<Copyright>Copyright 2017 © 1TCompany AB. All rights reserved.</Copyright>
<PackageTags>logger exceptions analysis .net-core netstandard</PackageTags>
<PackageIconUrl>http://coderrapp.com/images/nuget_icon.png</PackageIconUrl>
<RepositoryUrl>https://github.com/coderr/coderr.server</RepositoryUrl>
<PackageIconUrl>https://coderr.io/images/nuget_icon.png</PackageIconUrl>
<RepositoryUrl>https://github.com/coderrio/coderr.server</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseUrl>https://raw.githubusercontent.com/coderr/codeRR.Server/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://coderrapp.com</PackageProjectUrl>
<RootNamespace>Coderr.Server.Api.Client</RootNamespace>
<AssemblyName>Coderr.Server.Api.Client</AssemblyName>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://coderr.io</PackageProjectUrl>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DotNetCqs" Version="2.0.14" />
<PackageReference Include="DotNetCqs" Version="2.0.15" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.6.0" />
</ItemGroup>
<ItemGroup>
Expand Down
26 changes: 13 additions & 13 deletions src/Server/Coderr.Server.Api/Coderr.Server.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>1.1.0</Version>
<Version>2.1.4</Version>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Coderr.Server.Api.xml</DocumentationFile>
<PackageReleaseNotes>Added the whitelist API</PackageReleaseNotes>
</PropertyGroup>
<PropertyGroup>
<RootNamespace>Coderr.Server.Api</RootNamespace>
<AssemblyName>Coderr.Server.Api</AssemblyName>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\codeRR.Server.Api.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<PackageId>codeRR.Server.Api</PackageId>
<PackageId>Coderr.Server.Api</PackageId>
<Authors>1TCompany AB</Authors>
<Description>CQRS API definition for codeRR Server.</Description>
<Description>API object definitions for Coderr Server, use the ApiClient package to communicate with the Coderr Server.</Description>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>First release</PackageReleaseNotes>
<Copyright>Copyright 2017 © 1TCompany AB. All rights reserved.</Copyright>
<Copyright>Copyright 2019 © 1TCompany AB. All rights reserved.</Copyright>
<PackageTags>logger exceptions analysis .net-core netstandard</PackageTags>
<PackageIconUrl>http://coderrapp.com/images/nuget_icon.png</PackageIconUrl>
<RepositoryUrl>https://github.com/coderr/coderr.server</RepositoryUrl>
<PackageIconUrl>https://coderr.io/images/nuget_icon.png</PackageIconUrl>
<RepositoryUrl>https://github.com/coderrio/coderr.server</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseUrl>https://raw.githubusercontent.com/coderr/codeRR.Server/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://coderrapp.com</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://coderr.io</PackageProjectUrl>
</PropertyGroup>
<PropertyGroup>
<NoWarn>1701;1702;1705;1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DotNetCqs" Version="2.0.14" />
<PackageReference Include="DotNetCqs" Version="2.0.15" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
<Reference Include="System.Net.Http" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Coderr.Server.Api.Modules.Whitelists.Commands
{
/// <summary>
/// Add a domain that may post error reports without using a shared secret (javascript applications)
/// </summary>
[Command]
public class AddEntry
{
/// <summary>
/// Applications that the domain is allowed for.
/// </summary>
public int[] ApplicationIds { get; set; } = new int[0];

/// <summary>
/// For instance <c>yourdomain.com</c>.
/// </summary>
public string DomainName { get; set; }

/// <summary>
/// To manually specify which IP addresses the domain matches.
/// </summary>
public string[] IpAddresses { get; set; } = new string[0];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Coderr.Server.Api.Modules.Whitelists.Commands
{
/// <summary>
/// Edit a domain that may post error reports without using a shared secret (javascript applications)
/// </summary>
[Command]
public class EditEntry
{
/// <summary>
/// PK for the entry being edited.
/// </summary>
public int Id { get; set; }

/// <summary>
/// Applications that the domain is allowed for.
/// </summary>
public int[] ApplicationIds { get; set; } = new int[0];


/// <summary>
/// Only manually specified ip addresses.
/// </summary>
public string[] IpAddresses { get; set; } = new string[0];
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace Coderr.Server.ReportAnalyzer.Abstractions.Inbound.Whitelists.Commands
namespace Coderr.Server.Api.Modules.Whitelists.Commands
{
/// <summary>
/// Remove a previously added white list entry
/// </summary>
[Command]
public class RemoveEntry
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using Coderr.Server.Api;
using DotNetCqs;
using DotNetCqs;

namespace Coderr.Server.ReportAnalyzer.Abstractions.Inbound.Whitelists.Queries
namespace Coderr.Server.Api.Modules.Whitelists.Queries
{
/// <summary>
/// Get whitelist either by application id or DomainName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Coderr.Server.ReportAnalyzer.Abstractions.Inbound.Whitelists.Queries
namespace Coderr.Server.Api.Modules.Whitelists.Queries
{
/// <summary>
/// Result for <see cref="GetWhitelistEntries"/>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
namespace Coderr.Server.ReportAnalyzer.Abstractions.Inbound.Whitelists.Queries
namespace Coderr.Server.Api.Modules.Whitelists.Queries
{
/// <summary>
/// Entry for <see cref="GetWhitelistEntriesResult"/>
/// </summary>
public class GetWhitelistEntriesResultItem
{
public int Id { get; set; }
public int? ApplicationId { get; set; }
public GetWhitelistEntriesResultItemIp[] IpAddresses { get; set; }
public GetWhitelistEntriesResultItemApp[] Applications { get; set; }
public string DomainName { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Coderr.Server.Api.Modules.Whitelists.Queries
{
public class GetWhitelistEntriesResultItemApp
{
public int ApplicationId { get; set; }
public string Name { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace Coderr.Server.Api.Modules.Whitelists.Queries
{
public class GetWhitelistEntriesResultItemIp
{
public string Address { get; set; }
public DateTime UpdatedAtUtc { get; set; }
public ResultItemIpType Type { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Coderr.Server.Api.Modules.Whitelists.Queries
{
/// <summary>
/// Typ of stored IP record.
/// </summary>
public enum ResultItemIpType
{
/// <summary>
/// Added when doing a lookup for the domain
/// </summary>
Lookup = 0,

/// <summary>
/// Manually specified by the user
/// </summary>
Manual = 1,

/// <summary>
/// We got a request from this IP and a lookup didn't match it.
/// </summary>
Denied = 2
}
}
5 changes: 3 additions & 2 deletions src/Server/Coderr.Server.App/Coderr.Server.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
<PackageReference Include="ColorCode" Version="1.0.1">
<NoWarn>NU1701</NoWarn>
</PackageReference>
<PackageReference Include="DotNetCqs" Version="2.0.14" />
<PackageReference Include="DnsClient" Version="1.2.0" />
<PackageReference Include="DotNetCqs" Version="2.0.15" />
<PackageReference Include="Griffin.Framework" Version="2.1.1" />
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Markdig" Version="0.17.1" />
<PackageReference Include="Markdig" Version="0.18.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="UAParser" Version="3.1.43" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public async Task HandleAsync(IMessageContext context, CloseIncident command)
if (command == null) throw new ArgumentNullException("command");

var incident = await _repository.GetAsync(command.IncidentId);
incident.Close(command.UserId, command.Solution);
incident.Close(command.UserId, command.Solution, command.ApplicationVersion);
if (command.ShareSolution)
incident.ShareSolution();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;

namespace Coderr.Server.App.Modules.Whitelists
{
/// <summary>
/// Whitelists is used for reports that don't use a shared secret
/// </summary>
public interface IWhitelistRepository
{
Task<WhitelistedDomainIp> FindIp(int applicationId, IPAddress address);
Task<IReadOnlyList<Whitelist>> FindWhitelists(int applicationId);

Task SaveIp(WhitelistedDomainIp entry);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Net;
using System.Threading.Tasks;

namespace Coderr.Server.App.Modules.Whitelists
{
/// <summary>
/// Used to validate origin of inbound requests when a shared secret is not used.
/// </summary>
public interface IWhitelistService
{
/// <summary>
/// Is domain white listed?
/// </summary>
/// <param name="appKey">AppKey used when receiving error reports.</param>
/// <param name="remoteAddress">IP address of the client reporting the error.</param>
/// <returns></returns>
Task<bool> Validate(string appKey, IPAddress remoteAddress);

/// <summary>
/// Is domain white listed?
/// </summary>
/// <param name="applicationId">Application that the error is reported for.</param>
/// <param name="remoteAddress">IP address of the client reporting the error.</param>
/// <returns></returns>
Task<bool> Validate(int applicationId, IPAddress remoteAddress);
}
}
23 changes: 23 additions & 0 deletions src/Server/Coderr.Server.App/Modules/Whitelists/IpType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Coderr.Server.App.Modules.Whitelists
{
/// <summary>
/// Typ of stored IP record.
/// </summary>
public enum IpType
{
/// <summary>
/// Added when doing a lookup for the domain
/// </summary>
Lookup = 0,

/// <summary>
/// Manually specified by the user
/// </summary>
Manual = 1,

/// <summary>
/// We got a request from this IP and a lookup didn't match it.
/// </summary>
Denied = 2
}
}
28 changes: 28 additions & 0 deletions src/Server/Coderr.Server.App/Modules/Whitelists/Whitelist.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Coderr.Server.App.Modules.Whitelists
{
/// <summary>
/// Domain that is allowed to report errors without
/// </summary>
public class Whitelist
{
/// <summary>
/// Domain name, must be an exact match. Can also be an IP address
/// </summary>
public string DomainName { get; set; }

/// <summary>
/// PK
/// </summary>
public int Id { get; set; }

/// <summary>
/// Addresses that have been stored for this domain
/// </summary>
public WhitelistedDomainIp[] IpAddresses { get; set; }

/// <summary>
/// Applications that this whitelist is allowed for
/// </summary>
public int[] ApplicationIds { get; set; }
}
}
Loading