Coder Social home page Coder Social logo

device-detection-dotnet's People

Contributors

arturadam avatar automation51d avatar ben51degrees avatar dependabot[bot] avatar drasmart avatar fatima51degrees avatar jamesr51d avatar joseph51d avatar justadreamer avatar jwrosewell avatar pi-alexander-popel avatar piotr-grabalski avatar steve51d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

device-detection-dotnet's Issues

expose DataUpdate[Url,VerifyMd5,UseUrlFormatter] on DeviceDetectionOnPremisePipelineBuilder

Background

Documentation on the automatic data file updates feature mentions that there are 3 properties that control the behavior:

  • DataUpdateUrl
  • DataUpdateVerifyMd5
  • DataUpdateUseUrlFormatter

These properties are exposed via the json configuration, but are not exposed on the DeviceDetectionOnPremisePipelineBuilder

Objective

  1. Expose these parameters via setters / getters accordingly on the builder
  2. Propagate the values to the underlying classes so the logic works the same as if they were read from the configuration file
  3. Cover the behaviors with the according unit tests, verifying the according behaviors when these parameters are passed via the builder
  4. Verify if there are tests covering the behaviors when these parameters are passed via configuration.
    For DataUpdateUrl - you might need to run an inprocess http server that would allow to download 51degreesHashV41-Lite.hash.gz to verify the vehaviors.

"cannot open shared object file: No such file or directory" with version 4.4.23

Hi, me again! We updated to version 4.4.23 to use the navigator values and UachJsConversionElementBuilder, but even with RUN apt install libatomic1 we are getting this again:

System.Exception: Failed to load the Device Detection native library, common causes include: 
    - Missing dependencies:
        o On Windows, the Visual C++ runtime is not installed, see the Visual Studio download page for the latest C++ Redistributable: https://visualstudio.microsoft.com/downloads/
        o On Linux, the libatomic shared object is missing. On Debian based distributions, run ‘apt install libatomic1’; on RedHat based distributions, run ‘<yum|dnf> install libatomic’.
    - The DLL file was not copied to the output directory during build, refer to the ‘System.DllNotFoundException’ inner exception for the exact library file name.
    - The incorrect DLL was copied to the output directory, this maybe be caused by the build chain determining the incorrect platform or the incorrect platform has been specified in the build process. If using the dotnet command, see https://docs.microsoft.com/en-us/dotnet/core/rid-catalog to specify the correct runtime. If using Visual Studio, make sure the selected Platform (x86/x64) matches your environment.
    - If building for .NET Framework, the AnyCPU configuration is not supported, make sure to build for the required Platform (x86/x64).
 ---> System.TypeInitializationException: The type initializer for 'FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libFiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll: cannot open shared object file: No such file or directory
   at void FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE+SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_DeviceDetectionHashEngineModule(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate)
   at static FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE+SWIGExceptionHelper()
   --- End of inner exception stack trace ---
   at new FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE+SWIGExceptionHelper()
   at static FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE()
   --- End of inner exception stack trace ---
   at IntPtr FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE.new_ConfigHashSwig()
   at new FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.ConfigHashSwig()
   at IConfigSwigWrapper FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Wrappers.SwigFactory+<>c.<.ctor>b__4_7(?)+() => { }
   at T FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Wrappers.SwigFactory.DllExceptionHandler<T>(Func<T> action)
   --- End of inner exception stack trace ---
   at T FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Wrappers.SwigFactory.DllExceptionHandler<T>(Func<T> action)
   at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Wrappers.SwigFactory()+() => { } [3]
   at IConfigSwigWrapper FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Wrappers.SwigFactory.CreateConfig()
   at IConfigSwigWrapper FiftyOne.DeviceDetection.Hash.Engine.OnPremise.FlowElements.DeviceDetectionHashEngineBuilder.get_SwigConfig()
   at DeviceDetectionHashEngineBuilder FiftyOne.DeviceDetection.Hash.Engine.OnPremise.FlowElements.DeviceDetectionHashEngineBuilder.SetPerformanceProfile(PerformanceProfiles profile)
   at TEngine FiftyOne.DeviceDetection.DeviceDetectionOnPremisePipelineBuilder.ConfigureAndBuild<TBuilder, TEngine>(OnPremiseDeviceDetectionEngineBuilderBase<TBuilder, TEngine> builder)
   at IPipeline FiftyOne.DeviceDetection.DeviceDetectionOnPremisePipelineBuilder.Build()

Can you help me figure out what to do here?

Too many file handles have been created during initialisation

Running .NET Framework 4.8 in IIS from onprem file 51Degrees-LiteV4.1.hash and getting the following error:

"Too many file handles have been created during initialisation."

Code:

using (var pipeline = new FiftyOne.DeviceDetection.DeviceDetectionPipelineBuilder().UseOnPremise(fileName, null).Build())
{
using (var data = pipeline.CreateFlowData())
{
data.AddEvidence(FiftyOne.Pipeline.Core.Constants.EVIDENCE_QUERY_USERAGENT_KEY, userAgent);
data.Process();
var result = data.Get<FiftyOne.DeviceDetection.IDeviceData>();
var value = result.IsMobile.Value;
return value;
}
}

The error is on the first row (the Build method):

FiftyOne.DeviceDetection.Hash.Engine.OnPremise
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.EngineHashSwig..ctor(String fileName, ConfigHashSwig config, RequiredPropertiesConfigSwig properties)
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Wrappers.SwigFactory.<>c.<.ctor>b__4_0(String fileName, IConfigSwigWrapper config, IRequiredPropertiesConfigSwigWrapper requiredProperties)
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Wrappers.SwigFactory.CreateEngine(String fileName, IConfigSwigWrapper config, IRequiredPropertiesConfigSwigWrapper requiredProperties)
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.FlowElements.DeviceDetectionHashEngine.RefreshData(String dataFileIdentifier)
at FiftyOne.Pipeline.Engines.FlowElements.OnPremiseAspectEngineBase2.AddDataFile(IAspectEngineDataFile dataFile) at FiftyOne.DeviceDetection.Shared.FlowElements.OnPremiseDeviceDetectionEngineBase1.AddDataFile(IAspectEngineDataFile dataFile)
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.FlowElements.DeviceDetectionHashEngineBuilder.NewEngine(List1 properties) at FiftyOne.Pipeline.Engines.FlowElements.AspectEngineBuilderBase2.BuildEngine()
at FiftyOne.Pipeline.Engines.FlowElements.SingleFileAspectEngineBuilderBase2.Build() at FiftyOne.Pipeline.Engines.FlowElements.SingleFileAspectEngineBuilderBase2.Build(String datafile, Boolean createTempDataCopy)
at FiftyOne.DeviceDetection.DeviceDetectionOnPremisePipelineBuilder.ConfigureAndBuild[TBuilder,TEngine](OnPremiseDeviceDetectionEngineBuilderBase`2 builder)
at FiftyOne.DeviceDetection.DeviceDetectionOnPremisePipelineBuilder.Build()

Cloud request timeout messages

One of our clients has reported a high number of errors when calling the cloud service.
The error message returned is : 'waiting for response from the cloud service.'
The issue is seen across genuine user agents as well as crawlers.
The question raised is if this could be due to throttling when the number of requests is high?
See attached error message.
Image

Tac Intelligence service

Hello Good Day
I am doing a demo for TAC intelligence service with C#.
But Im getting this error

'Failed to load aspect properties for element 'hardware'. This is because your resource key does not include access to any properties under 'hardware'.

I am trying to use these Resource keys for the demo. I selected the property HardwareVendor and HardwareModel.
AQTJih7vx8Sml9Mi2Ug or AQTJih7v-a4hFtAi2Ug

Do I need a special resource key with privileges??

Im using this code, I get it from 51degrees website

using FiftyOne.DeviceDetection.Cloud.Data;
using FiftyOne.DeviceDetection.Cloud.FlowElements;
using FiftyOne.DeviceDetection.Shared;
using FiftyOne.Pipeline.CloudRequestEngine.FlowElements;
using FiftyOne.Pipeline.Core.FlowElements;
using GettingStarted;
using Microsoft.Extensions.Logging;
using System;
using System.Net.Http;
namespace FiftyOne.DeviceDetection.Examples.Cloud.TacLookup
{
public class Program
{
public class Example
{
private static string TAC = "35925406";
private static string TAC2 = "86386802";
public void Run(string resourceKey, string cloudEndPoint = "")
{
Console.WriteLine("This example shows the details of devices " +
"associated with a given 'Type Allocation Code' or 'TAC'.");
Console.WriteLine("More background information on TACs can be " +
"found through various online sources such as Wikipedia: " +
"https://en.wikipedia.org/wiki/Type_Allocation_Code");
Console.WriteLine("----------------------------------------");
ILoggerFactory loggerFactory = new LoggerFactory();
HttpClient httpClient = new HttpClient();
// Create a cloud request engine builder
var cloudRequestEngineBuilder = new CloudRequestEngineBuilder(loggerFactory, httpClient)
.SetResourceKey(resourceKey);
// If a cloud endpoint has been provided then set the
// cloud pipeline endpoint.
if (string.IsNullOrWhiteSpace(cloudEndPoint) == false)
{
cloudRequestEngineBuilder.SetEndPoint(cloudEndPoint);
}
// Create the cloud request engine
using (var cloudEngine = cloudRequestEngineBuilder.Build())
// Create the property-keyed engine to process the
// response from the request engine.
using (var propertyKeyedEngine = new HardwareProfileCloudEngineBuilder(loggerFactory)
.Build())
// Create the pipeline using the engines.
using (var pipeline = new PipelineBuilder(loggerFactory)
.AddFlowElement(cloudEngine)
.AddFlowElement(propertyKeyedEngine)
.Build())
{
// Pass a TAC into the pipeline and list the matching devices.
AnalyseTac(TAC, pipeline);
AnalyseTac(TAC2, pipeline);
}
}
static void AnalyseTac(string tac, IPipeline pipeline)
{
// Create the FlowData instance.
using (var data = pipeline.CreateFlowData())
{
// Add the TAC as evidence.
data.AddEvidence(Constants.EVIDENCE_QUERY_TAC_KEY, tac);
// Process the supplied evidence.
data.Process();
// Get result data from the flow data.
var result = data.Get();
Console.WriteLine($"Which devices are associated with the TAC '{tac}'?");
foreach (var device in result.Profiles)
{
var vendor = device.HardwareVendor;
var name = device.HardwareName;
var model = device.HardwareModel;
// Check that the properties have values.
if (vendor.HasValue &&
model.HasValue &&
name.HasValue)
{
Console.WriteLine($"\t{vendor.Value} {string.Join(",", name.Value)} ({model.Value})");
}
else
{
Console.WriteLine(vendor.NoValueMessage);
}
}
}
}
}
static void Main(string[] args)
{

        // Obtain a resource key for free at https://configure.51degrees.com
        // Make sure to include the 'HardwareVendor' and 'HardwareModel' 
        // properties as they are used by this example.
        //string resourceKey = "AQTJih7v-a4hFtAi2Ug";
        string resourceKey = "AQTJih7vx8Sml9Mi2Ug";

        if (resourceKey.StartsWith("!!"))
        {
            Console.WriteLine("You need to create a resource key at " +
                "https://configure.51degrees.com and paste it into the code, " +
                "replacing !!YOUR_RESOURCE_KEY!!.");
            Console.WriteLine("Make sure to include the 'HardwareVendor', " +
                "'HardwareName' and 'HardwareModel' properties as they " +
                "are used by this example.");
        }
        else
        {
            new Example().Run(resourceKey);
        }

        Console.WriteLine("Done. Press any key to exit.");
        Console.ReadKey();

    }
}

}

screen1

https://51degrees.com/documentation/4.2/_info__resourcekeys.html

screen2

Cannot disable JavascriptBuilderElement and JsonBuilderElement

When using server-side Apple detection, it may be desirable to disable JavaScriptBuilderElement and JsonBuilderElement.
These elements add a significant performance penalty and are added to the pipeline by default if using the web integration package. However, they're not needed if server-side Apple detection is being used.

In the future, we plan to address this by improving the performance of these elements, adding more configuration options to limit the properties they include, and allow them to be fully disabled if needed.

For the moment, the only way to manage this is with the following workaround:

  1. Create a custom element that just sets FlowData.Stop = true. There is an example of this in our test suite.
  2. You'll also need a 'builder' class for this element. It just needs to contain a Build method that takes no parameters and returns a new instance of the StopElement similar to this.
  3. Modify your configuration to add the StopElement after all required elements and before the ones you want to skip. For example, to skip JavaScriptBuilderElement and JsonBuilderElement:
{
  "Elements": [
    {
      "BuilderName": "AppleProfileEngineBuilder",
      "BuildParameters": {
        ...
      }
    },
    {
      "BuilderName": "DeviceDetectionHashEngineBuilder",
      "BuildParameters": {
        ...
      }
    },
    {
      "BuilderName": "SetHeadersElementBuilder"
    },
    {
      "BuilderName": "StopElementBuilder"
    },
    {
      "BuilderName": "JsonBuilderElementBuilder"
    },
    {
      "BuilderName": "JavaScriptBuilderElementBuilder",
      "BuildParameters": {
        ...
      }
    }
  ]
}

Performance issue in returning the response

Hi,

I've been facing performance issues with the NuGet package. The response time takes on average over 600ms and sometimes it has even gone to more than a second.

One of the reasons could be because the CloudRequestEngineBuilder function takes HttpClient as one of the inputs. From what I understand, HttpClient has some performance issues. You can check this Reddit Discussion

It would be great if the function can take other providers like RestSharp or WebRequest so consumers can use whichever providers they like.

Attached below screenshots of my tests and the code I used.

Appreciate your help on this.

test1
test2
test3

Program.txt

AccessViolationException

I have attached a sample project that crashes with "AccessViolationException: Attempting to read or write protected memory".

image

Please see the attached project for the test case to reproduce the issue. Please note that there are two constants that need to be set the at top of file "DeviceInfoDetection" before this sample can be run (the path to "Enterprise-HashV41.hash" and the License Key).

51degrees_tester_crash.zip

I was not sure where to file this issue since my test case is written in C#, bu the actual issue is likely in underlying C code. Apologies if I am at the wrong place.

Unable to establish a secure connection to 51Degrees library's HTTPS endpoint

A client is facing an issue where they are unable to establish a secure connection to 51Degrees library's HTTPS endpoint from our code.

The update code which is executed looks like:
using (var pipeline = new FiftyOne.DeviceDetection.DeviceDetectionPipelineBuilder(loggerFactory)
.UseOnPremise(_hashFile, _licenseKey, false)
.SetDataFileSystemWatcher(true)
.SetShareUsage(false)
.SetAutoUpdate(true)
.SetDataUpdateOnStartUp(true)
.SetUpdatePollingInterval(_pollingIntervalMinutes * 60)
.SetUpdateRandomisationMax(_updateRandomisationMaxMinutes * 60)
.Build())
{
// Hash file successfully updated
}

The error occurs when the file is already updated - updating an older file is working correctly.

The error message:
Error accessing data update service at 'https://distributor.51degrees.com/api/v2/download?LicenseKeys=&Download=True&Type=HashV41' for engine 'DeviceDetectionHashEngine'

The error message status:
FiftyOne.Pipeline.Engines.Services.AutoUpdateStatus.AUTO_UPDATE_HTTPS_ERR

They have checked their network settings to ensure that there are no restrictions or firewalls blocking the HTTPS connection and also tested their code against other HTTPS endpoints successfully, confirming that the issue seems specific to the connection with the 51Degrees library.

Development Environment Details:

Programming Language: C# libary .netstandard2.0
Operating System: Windows
Version of the 51Degrees software library:
FiftyOne.DeviceDetection:4.4.23
FiftyOne.DeviceDetection.Hash.Engine.OnPremise:4.4.23

Add Project URL into Nuget package

Please add "Project URL" pointing to a Github project repository into each of your NET libraries.
It will help everyone to quickly go to the project source and learn the change history.

How to provide client hint evidence from the Javascript API

Hello,

We've found out that the Javascript API exposes a call that will return low- and high entropy user agent client hints without needing Accept-CH and Permission-Policy headers. However, the key names and formatting of the values is a bit different than what we receive through response headers. I receive the following from Google Chrome with the navigator.userAgentData.getHighEntropyValues call:

  • brands [{"brand":" Not A;Brand","version":"99"},
    {"brand":"Chromium","version":"98"},
    {"brand":"Google Chrome","version":"98"}]
  • mobile: false
  • platform: Windows
  • platformVersion: 10.0.0
  • architecture: x86
  • bitness: 64
  • model: empty
  • uaFullVersion: 98.0.4758.102

Whereas response headers present data like this:

  • Sec-CH-UA: " Not A;Brand";v="99", "Chromium";v="98", "Google Chrome";v="98"
  • Sec-CH-UA-Platform: "Windows"
  • Sec-CH-UA-Mobile": ?0
  • Sec-CH-UA-Full-Version: "98.0.4758.102"
  • Sec-CH-UA-Platform-Version: "10.0.0"
  • Sec-CH-UA-Arch: "x86"
  • Sec-CH-UA-Bitness: "64"
  • Sec-CH-UA-Model: ""

Notice the difference in key names, formatting of brands where the JS API uses newline separators and the response headers a ";", the usage of quotes etc.

How should we provide the evidence we receive from the JS API? Should we convert it to the response header naming and formatting, or use different prefixes when adding it to the flowdata?

Looking forward to your response.

Best regards,
Martijn

Running in AWS Lambda

Hi, I am attempting to use FiftyOne.DeviceDetection version 4.4.16 in AWS Lambda, which is running .NET 6 (identifier dotnet6) which uses an OS called Amazon Linux 2. I do not believe it is possible to run apt install libatomic1 in the Lambda as it's a ZIP deployment, however I have not tried a Docker deployment (a related app running in Docker works after running apt install libatomic1). In this environment, I get the dreaded:

System.DllNotFoundException: Unable to load shared library 'FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libFiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll: cannot open shared object file: No such file or directory

Could you suggest me ideas on how to proceed here?

Native dll gets copied to the webroot as well as to the bin folder

I've discovered another possible issue.

When I publish from visual Studio the following dll gets copied to the webroot (same level as the web.config) as well as to the bin folder:
FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll

Obviously it should be copied just to the bin folder. I wonder if you could fix this behaviour.

Thanks
valgen

Originally posted by @valgen in #13 (comment)

Errors when using the web integration example with the lite data file - Could not find property 'Promise'/'Fetch'.

Hi all,

I am migrating from ASP.Net MVC 5 to Asp.Net Core 6 and I made an empty project just to test device detection because we use it a lot and I have a couple of issues.

First of them is this code in Program.cs

builder.Services.AddSingleton<DeviceDetectionHashEngineBuilder>(); builder.Services.AddFiftyOne(builder.Configuration);

After adding the last line, Hot reload feature stops working and I can not see any UI changes (.cshtml file) without rebuilding the application or restarting it.

Also on every page load I see this error in console

fail: FiftyOne.Pipeline.Core.FlowElements.Pipeline[0]
Could not find property 'Promise'.
fail: FiftyOne.Pipeline.Core.FlowElements.Pipeline[0]
Could not find property 'Fetch'.

image

I followed this example https://51degrees.com/device-detection-dotnet/4.3/_asp_net_core3_81_2_startup_8cs-example.html

What might be the problem ?

Information provided through some client hints seems to be ignored

I've noticed some information in the client hints seems to be ignored. When I provide the browser version with the client hint sec-ch-ua-full-version, for example 97.0.4692.99 I can only retrieve 97 from the DeviceData. What happens to the minor version?
What's more is that I can provide information about the bitness or architecture with the client hints sec-ch-ua-bitness: 64 and sec-ch-ua-arch: x86 which I'm not seeing back in any way in the device data. I'd expect some assumptions can be made about the hardware or device with this information.

NON-Core asp.net (full dot-net) example

Where can I find a dot-net library (not dot-net Core) example that sets Request.Browser["IsMobile"] for an asp.net IIS web site project?
The upgrade instruction on the 51 degrees website contains code for Global.asax.cs that I cannot get to compile. The errors are:

  1. The type or namespace name 'JavaScriptBuilderElement' could not be found (are you missing a using directive or an assembly reference?)
  2. The type or namespace name 'JsonBuilderElement' could not be found (are you missing....
  3. The type or namespace name 'DeviceDetectionHashEngineBuilder' could not be found (are you missing....

We are upgrading from version 3.x for an asp.net web site project (not a web application project). I followed the directions at: https://51degrees.com/documentation/4.4/_device_detection__migration_guides_51_degrees_v3.html

Failed to load the Device Detection native library after updating to Version 4.4.12

Hi,

I need to mention this issue which was closed sometimes ago: #13 (comment)
In the above issue I was forced to set my project Active Platform to "x64" to work properly.

With version 4.4.12 you have introduced a change where the Native DLLs are copied to the runtimes directory, not the root of the bin directory, and the default for AnyCPU is x64 instead of x86.

Unfortunately this change has broken my project and I started receiving "Failed to load the Device Detection native library" errors at runtime.

To fix this issue I had to set my project Active Platform to "Any CPU".
Unfortunately it only works in debug mode.
When I publish and release, the native dll doesn't get copied to the root of the bin directory anymore.
Only the runtimes directory gets created and it gets ignored at runtime, causing the error mentioned before.

FYI my project is built with .NET Framework 4.8 (not .NET Core).

CentOS 7 support

Right now libFiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll depends on glibc 2.27. Unfortunately, CentOS 7 supports only glibc 2.17. Would it be possible to compile device detection library with an older glibc?

$ ldd runtimes/linux-x64/native/libFiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll 
runtimes/linux-x64/native/libFiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by runtimes/linux-x64/native/libFiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll)
	linux-vdso.so.1 =>  (0x00007ffea0f2e000)
	libatomic.so.1 => /lib64/libatomic.so.1 (0x00007f2745131000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f2744e2f000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2744c13000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f2744845000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f2745720000)

Crash when using a cloud resource key that includes the SupportedI/O property

To reproduce:

  • Create a new resource key that includes the Supported I/O property.
  • Create a new .NET project
  • Add a reference to FfityOne.DeviceDetection
  • Use the DeviceDetectionPipelineBuilder to create a pipeline using the cloud service, passing the resource key created above.

When creating the pipeline, the program will crash with the following error:

FiftyOne.Pipeline.Core.Exceptions.PipelineException: Unable to determine the type associated with this property. No c# property found matching definition DeviceDataCloud.SupportedI/O and json type 'Array' is not mapped.

This is because the cloud service property meta-data (accessible at https://cloud.51degrees.com/api/v4/accessibleproperties?resource=[RESOURCE_KEY]) only gives the json 'type' of each property.
For strongly-typed languages, we need to translate this into the real type. This is generally simple, but presents a problem for properties like Supported I/O where the json type is Array.

For .NET, we need to translate this into IAsectPropertyValue<IReadOnlyList<string>>. Rather than making any assumptions, we use the name of the property from the meta-data and reflection in order to get the type from the associated strongly-typed property.

In this case, that doesn't work because the name in the meta-data - SupportedI/O does not match the name of the property in code SupportedIO.

This will be fixed in a future release.
If you experience this problem in the meantime, then please let us know by commenting below.

Remove echoing the parameter values in the error response

Background

The error message is echoing the parameter value that was in the wrong format:

<value>Evidence value for key '{0}' is not in the expected format. This should be a base 64 encoded JSON string from a JavaScript call to navigator.userAgentData.getHighEntropyValues. Supplied value was '{1}'</value>
. This apparently is there for the engineer convenience.

This will appear on a page that will never be visible to the user and will be consumed by javascript and at most the results can be made visible through debug logging.

However it may not be desirable as it causes some security scanners to false-alarm and mis-report the vulnerability. The POST body may deliberately contain the URL-encoded HTML piece, that will be url-decoded and quoted in the response. It will then be detected by the scanner and make the alarm go off.

Fix

Let's remove quoting the wrong value of the parameter in the response - that will not let the HTML injection to happen. Even though on the invisible page it does not do any harm.

Getting error stating NuGet pulled files not being Strong Named when using Strong Name Key signing

When using the Strong Name Key signing the following error messages about the NuGet pulled files not being Strong Named are seen:

(0): error CS1577: Assembly generation failed -- Referenced assembly 'FiftyOne.Pipeline.CloudRequestEngine' does not have a strong name

(0): error CS1577: Assembly generation failed -- Referenced assembly 'FiftyOne.DeviceDetection.Cloud' does not have a strong name

(0): error CS1577: Assembly generation failed -- Referenced assembly 'FiftyOne.Pipeline.JavaScriptBuilderElement' does not have a strong name

(0): error CS1577: Assembly generation failed -- Referenced assembly 'FiftyOne.Pipeline.JsonBuilder' does not have a strong name

(0): error CS1577: Assembly generation failed -- Referenced assembly 'FiftyOne.Pipeline.Engines.FiftyOne' does not have a strong name

Crash when targeting AnyCPU

Following on from #13

When solution platform is set to 'AnyCPU', the device detection NuGet package will attempt to load the 32-bit native dll for device detection. If a 64-bit process is being used then this will cause an error similar to the following:

The type initializer for 'FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE' threw an exception.
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE.new_ConfigHashSwig()
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.ConfigHashSwig..ctor()
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Wrappers.SwigFactory.<>c.<.ctor>b__4_3()
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.FlowElements.DeviceDetectionHashEngineBuilder.get_SwigConfig()
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.FlowElements.DeviceDetectionHashEngineBuilder.SetPerformanceProfile(PerformanceProfiles profile)
at FiftyOne.DeviceDetection.DeviceDetectionOnPremisePipelineBuilder.ConfigureAndBuild[TBuilder,TEngine](OnPremiseDeviceDetectionEngineBuilderBase`2 builder)
at FiftyOne.DeviceDetection.DeviceDetectionOnPremisePipelineBuilder.Build()
at project1.Models.FiftyOneDegrees.GetDevice() in C:\Users\user1\source\Workspaces\workspace\project1\project1\Models\FiftyOneDegrees.cs:line 151

The type initializer for 'SWIGExceptionHelper' threw an exception.
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE.SWIGExceptionHelper..ctor()
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE..cctor()

An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_DeviceDetectionHashEngineModule(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate)
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE.SWIGExceptionHelper..cctor()

Building Examples using AnyCPU causes errors

This only affects users that build directly from the solution file.
This is unlikely in practice as most people will just use the NuGet packages.

The problem is that the native DLLs are not produced in an AnyCPU flavour. Consequently, the build fails with a message like:

Could not copy the file "D:\Workspace\Pipeline\pipeline-dotnet\FiftyOne.DeviceDetection\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native\AnyCPU\Debug\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.pdb" because it was not found.

This can be resolved by removing the AnyCPU configuration from the solution file.

Low CI Performance Figures

Performance figures from the CI tests are extremely low. One cause could be a single request to the process endpoint which is failing due to an exception from a non-match not being handled:
image

Avif?

Any chance we could get avif support data?

Distributor Info call - Missing Hash

When calling /info to retrieve the product information it sometimes happens that the hash field is empty. Admittedly this only happens intermittently during our automated builds.

This issue may be related to #7 .

Run tests against .NET 6

.NET 6 is the next LTS version of .NET

We need to modify our CI scripts to run the existing tests against this new version and address any issues.

Using this library with .NET framework 4.8 and Visual Studio 2017

Hi,

I would like to use this library in a WEB application with .NET framework 4.8 and Visual Studio 2017. Is it possible?

Unfortunately I get an exception when I try to execute this code:
new DeviceDetectionPipelineBuilder().UseOnPremise(HostingEnvironment.MapPath("~/App_Data/51Degrees-LiteV4.1.hash"), null, false).SetPerformanceProfile(PerformanceProfiles.LowMemory).Build()

This is the exception (including the inner exceptions):

The type initializer for 'FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE' threw an exception.
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE.new_ConfigHashSwig()
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.ConfigHashSwig..ctor()
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Wrappers.SwigFactory.<>c.<.ctor>b__4_3()
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.FlowElements.DeviceDetectionHashEngineBuilder.get_SwigConfig()
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.FlowElements.DeviceDetectionHashEngineBuilder.SetPerformanceProfile(PerformanceProfiles profile)
at FiftyOne.DeviceDetection.DeviceDetectionOnPremisePipelineBuilder.ConfigureAndBuild[TBuilder,TEngine](OnPremiseDeviceDetectionEngineBuilderBase`2 builder)
at FiftyOne.DeviceDetection.DeviceDetectionOnPremisePipelineBuilder.Build()
at project1.Models.FiftyOneDegrees.GetDevice() in C:\Users\user1\source\Workspaces\workspace\project1\project1\Models\FiftyOneDegrees.cs:line 151

The type initializer for 'SWIGExceptionHelper' threw an exception.
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE.SWIGExceptionHelper..ctor()
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE..cctor()

An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_DeviceDetectionHashEngineModule(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate)
at FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Interop.DeviceDetectionHashEngineModulePINVOKE.SWIGExceptionHelper..cctor()

Thanks
valgen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.