Skip to content

Commit

Permalink
Merge pull request #129 from regulaforensics/develop
Browse files Browse the repository at this point in the history
develop -> master
  • Loading branch information
KirylKovaliov authored Oct 7, 2024
2 parents b5c788b + 68d57d1 commit c1a6a0c
Show file tree
Hide file tree
Showing 16 changed files with 1,089 additions and 39 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/sast.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Semgrep SAST

on:
pull_request:
branches:
- develop
- staging
- production
- stable
- main
- master

env:
# Fail workflow or not if vulnerabilities found
FAIL_ON_VULNERABILITIES: true
# List of paths (space separated) to ignore
# Supports PATTERNS
# EXCLUDE_PATHS: 'foo bar/baz file.txt dir/*.yml'
EXCLUDE_PATHS: '*docker-compose.y*ml'
# List of rules (space separated) to ignore
# EXCLUDE_RULES: 'generic.secrets.security.detected-aws-account-id.detected-aws-account-id'
# See https://github.com/semgrep/semgrep-rules for rules registry
EXCLUDE_RULES: ''

jobs:
semgrep:
name: semgrep-oss/scan
runs-on: ubuntu-latest
container:
image: semgrep/semgrep
steps:
- uses: actions/checkout@v4
- name: Scan
shell: bash
run: |
EXCLUDED_PATHS=()
if [[ ! -z $EXCLUDE_PATHS ]]; then
for path in $EXCLUDE_PATHS; do
EXCLUDED_PATHS+=("--exclude $path")
done
fi
EXCLUDED_RULES=()
if [[ ! -z $EXCLUDE_RULES ]]; then
for rule in $EXCLUDE_RULES; do
EXCLUDED_RULES+=("--exclude-rule $rule")
done
fi
if [[ $FAIL_ON_VULNERABILITIES == "true" ]]; then
semgrep scan --config auto ${EXCLUDED_PATHS[@]} ${EXCLUDED_RULES[@]} --error --verbose
elif [[ $FAIL_ON_VULNERABILITIES == "false" ]]; then
semgrep scan --config auto ${EXCLUDED_PATHS[@]} ${EXCLUDED_RULES[@]} --error --verbose || true
else
echo "Bad FAIL_ON_VULNERABILITIES env var value"
exit 1
fi
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
docreader:
image: regulaforensics/docreader:latest
volumes:
- ./regula.license:/app/extBin/unix_x64/regula.license
- ./regula.license:/app/extBin/unix_x64/regula.license
nginx:
image: nginx:alpine
ports:
Expand All @@ -13,4 +13,4 @@ services:
- ./conf/nginx.conf:/etc/nginx/nginx.conf
- ./conf/.htpasswd:/etc/nginx/.htpasswd
depends_on:
- docreader
- docreader
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<OutputType>Exe</OutputType>
<Product>DocumentReader WebClient Example</Product>
<PackageId>Regula.DocumentReader.NetCoreExampple</PackageId>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Regula.DocumentReader.WebClient\Regula.DocumentReader.WebClient.csproj" />
Expand Down
5 changes: 2 additions & 3 deletions src/Regula.DocumentReader.WebClient/Api/DocumentReaderApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ public RecognitionResponse Process(ProcessRequest processRequest, Dictionary<Str
else
processRequest.SystemInfo.License = License;

return new RecognitionResponse(this._processApi.ApiProcess(processRequest, headers, xRequestID));
return new RecognitionResponse(this._processApi.ApiProcessWithHttpInfo(processRequest, headers, xRequestID));
}


public async Task<RecognitionResponse> ProcessAsync(ProcessRequest processRequest)
{
return await ProcessAsync(processRequest, new Dictionary<String, String>(), default(string));
Expand All @@ -77,7 +76,7 @@ public async Task<RecognitionResponse> ProcessAsync(ProcessRequest processReques
else
processRequest.SystemInfo.License = License;

var response = await this._processApi.ApiProcessAsync(processRequest, headers, xRequestID, cancellationToken);
var response = await this._processApi.ApiProcessWithHttpInfoAsync(processRequest, headers, xRequestID, cancellationToken);

return new RecognitionResponse(response);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Regula.DocumentReader.WebClient/Api/ProcessApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,11 @@ public void AddDefaultHeader(string key, string value)
if (exception != null) throw exception;
}

var rawResponse = localVarResponse.Content;

return new ApiResponse<ProcessResponse>(localVarStatusCode,
localVarResponse.Headers.ToDictionarySafe(x => x.Name, x => string.Join(",", x.Value)),
(ProcessResponse) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(ProcessResponse)));
(ProcessResponse) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(ProcessResponse)), rawResponse);
}

/// <summary>
Expand Down
14 changes: 13 additions & 1 deletion src/Regula.DocumentReader.WebClient/Client/ApiResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,30 @@ public class ApiResponse<T>
/// </summary>
/// <value>The data.</value>
public T Data { get; private set; }


/// <summary>
/// Gets or sets the RawResponse
/// </summary>
/// <value>The data.</value>
public string RawResponse { get; private set; }

/// <summary>
/// Initializes a new instance of the <see cref="ApiResponse&lt;T&gt;" /> class.
/// </summary>
/// <param name="statusCode">HTTP status code.</param>
/// <param name="headers">HTTP headers.</param>
/// <param name="data">Data (parsed HTTP body)</param>
public ApiResponse(int statusCode, IDictionary<string, string> headers, T data)
/// <param name="rawResponse"></param>
public ApiResponse(int statusCode,
IDictionary<string, string> headers,
T data,
string rawResponse = null)
{
this.StatusCode= statusCode;
this.Headers = headers;
this.Data = data;
this.RawResponse = rawResponse;
}

}
Expand Down
142 changes: 142 additions & 0 deletions src/Regula.DocumentReader.WebClient/Model/BinaryDataResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* Regula Document Reader Web API
*
* Documents recognition as easy as reading two bytes. # Clients: * [JavaScript](https://github.com/regulaforensics/DocumentReader-web-js-client) client for the browser and node.js based on axios * [Java](https://github.com/regulaforensics/DocumentReader-web-java-client) client compatible with jvm and android * [Python](https://github.com/regulaforensics/DocumentReader-web-python-client) 3.5+ client * [C#](https://github.com/regulaforensics/DocumentReader-web-csharp-client) client for .NET & .NET Core
*
* The version of the OpenAPI document: 7.2.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*/

using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel.DataAnnotations;
using OpenAPIDateConverter = Regula.DocumentReader.WebClient.Client.OpenAPIDateConverter;

namespace Regula.DocumentReader.WebClient.Model
{
/// <summary>
/// BinaryDataResult
/// </summary>
[DataContract]
public partial class BinaryDataResult : IEquatable<BinaryDataResult>, IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="BinaryDataResult" /> class.
/// </summary>
/// <param name="nFields">Count of array fields.</param>
/// <param name="pArrayFields">pArrayFields.</param>
public BinaryDataResult(int nFields = default(int), List<TBinaryData> pArrayFields = default(List<TBinaryData>))
{
this.NFields = nFields;
this.PArrayFields = pArrayFields;
}

/// <summary>
/// Count of array fields
/// </summary>
/// <value>Count of array fields</value>
[DataMember(Name="nFields", EmitDefaultValue=false)]
public int NFields { get; set; }

/// <summary>
/// Gets or Sets PArrayFields
/// </summary>
[DataMember(Name="pArrayFields", EmitDefaultValue=false)]
public List<TBinaryData> PArrayFields { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class BinaryDataResult {\n");
sb.Append(" NFields: ").Append(NFields).Append("\n");
sb.Append(" PArrayFields: ").Append(PArrayFields).Append("\n");
sb.Append("}\n");
return sb.ToString();
}

/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public virtual string ToJson()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
}

/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="input">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object input)
{
return this.Equals(input as BinaryDataResult);
}

/// <summary>
/// Returns true if BinaryDataResult instances are equal
/// </summary>
/// <param name="input">Instance of BinaryDataResult to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(BinaryDataResult input)
{
if (input == null)
return false;

return
(
this.NFields == input.NFields ||
(this.NFields != null &&
this.NFields.Equals(input.NFields))
) &&
(
this.PArrayFields == input.PArrayFields ||
this.PArrayFields != null &&
input.PArrayFields != null &&
this.PArrayFields.SequenceEqual(input.PArrayFields)
);
}

/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
int hashCode = 41;
if (this.NFields != null)
hashCode = hashCode * 59 + this.NFields.GetHashCode();
if (this.PArrayFields != null)
hashCode = hashCode * 59 + this.PArrayFields.GetHashCode();
return hashCode;
}
}

/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}

}
27 changes: 22 additions & 5 deletions src/Regula.DocumentReader.WebClient/Model/ContainerList.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* Regula Document Reader Web API
*
* Regula Document Reader Web API
* Documents recognition as easy as reading two bytes. # Clients: * [JavaScript](https://github.com/regulaforensics/DocumentReader-web-js-client) client for the browser and node.js based on axios * [Java](https://github.com/regulaforensics/DocumentReader-web-java-client) client compatible with jvm and android * [Python](https://github.com/regulaforensics/DocumentReader-web-python-client) 3.5+ client * [C#](https://github.com/regulaforensics/DocumentReader-web-csharp-client) client for .NET & .NET Core
*
* The version of the OpenAPI document: 5.2.0
* The version of the OpenAPI document: 7.2.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
Expand All @@ -25,7 +25,7 @@
namespace Regula.DocumentReader.WebClient.Model
{
/// <summary>
/// list with result objects
/// List with various objects, containing processing results
/// </summary>
[DataContract]
public partial class ContainerList : IEquatable<ContainerList>, IValidatableObject
Expand All @@ -38,8 +38,9 @@ protected ContainerList() { }
/// <summary>
/// Initializes a new instance of the <see cref="ContainerList" /> class.
/// </summary>
/// <param name="count">Length of list (Count for items).</param>
/// <param name="list">list (required).</param>
public ContainerList(List<ResultItem> list = default(List<ResultItem>))
public ContainerList(int count = default(int), List<ResultItem> list = default(List<ResultItem>))
{
// to ensure "list" is required (not null)
if (list == null)
Expand All @@ -51,8 +52,16 @@ protected ContainerList() { }
this.List = list;
}

this.Count = count;
}

/// <summary>
/// Length of list (Count for items)
/// </summary>
/// <value>Length of list (Count for items)</value>
[DataMember(Name="Count", EmitDefaultValue=false)]
public int Count { get; set; }

/// <summary>
/// Gets or Sets List
/// </summary>
Expand All @@ -67,6 +76,7 @@ public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class ContainerList {\n");
sb.Append(" Count: ").Append(Count).Append("\n");
sb.Append(" List: ").Append(List).Append("\n");
sb.Append("}\n");
return sb.ToString();
Expand All @@ -78,7 +88,7 @@ public override string ToString()
/// <returns>JSON string presentation of the object</returns>
public virtual string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
}

/// <summary>
Expand All @@ -102,6 +112,11 @@ public bool Equals(ContainerList input)
return false;

return
(
this.Count == input.Count ||
(this.Count != null &&
this.Count.Equals(input.Count))
) &&
(
this.List == input.List ||
this.List != null &&
Expand All @@ -119,6 +134,8 @@ public override int GetHashCode()
unchecked // Overflow is fine, just wrap
{
int hashCode = 41;
if (this.Count != null)
hashCode = hashCode * 59 + this.Count.GetHashCode();
if (this.List != null)
hashCode = hashCode * 59 + this.List.GetHashCode();
return hashCode;
Expand Down
Loading

0 comments on commit c1a6a0c

Please sign in to comment.