Skip to content

Commit c1a6a0c

Browse files
Merge pull request #129 from regulaforensics/develop
develop -> master
2 parents b5c788b + 68d57d1 commit c1a6a0c

16 files changed

+1089
-39
lines changed

.github/workflows/sast.yaml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Semgrep SAST
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
- staging
8+
- production
9+
- stable
10+
- main
11+
- master
12+
13+
env:
14+
# Fail workflow or not if vulnerabilities found
15+
FAIL_ON_VULNERABILITIES: true
16+
# List of paths (space separated) to ignore
17+
# Supports PATTERNS
18+
# EXCLUDE_PATHS: 'foo bar/baz file.txt dir/*.yml'
19+
EXCLUDE_PATHS: '*docker-compose.y*ml'
20+
# List of rules (space separated) to ignore
21+
# EXCLUDE_RULES: 'generic.secrets.security.detected-aws-account-id.detected-aws-account-id'
22+
# See https://github.com/semgrep/semgrep-rules for rules registry
23+
EXCLUDE_RULES: ''
24+
25+
jobs:
26+
semgrep:
27+
name: semgrep-oss/scan
28+
runs-on: ubuntu-latest
29+
container:
30+
image: semgrep/semgrep
31+
steps:
32+
- uses: actions/checkout@v4
33+
- name: Scan
34+
shell: bash
35+
run: |
36+
EXCLUDED_PATHS=()
37+
if [[ ! -z $EXCLUDE_PATHS ]]; then
38+
for path in $EXCLUDE_PATHS; do
39+
EXCLUDED_PATHS+=("--exclude $path")
40+
done
41+
fi
42+
43+
EXCLUDED_RULES=()
44+
if [[ ! -z $EXCLUDE_RULES ]]; then
45+
for rule in $EXCLUDE_RULES; do
46+
EXCLUDED_RULES+=("--exclude-rule $rule")
47+
done
48+
fi
49+
50+
if [[ $FAIL_ON_VULNERABILITIES == "true" ]]; then
51+
semgrep scan --config auto ${EXCLUDED_PATHS[@]} ${EXCLUDED_RULES[@]} --error --verbose
52+
elif [[ $FAIL_ON_VULNERABILITIES == "false" ]]; then
53+
semgrep scan --config auto ${EXCLUDED_PATHS[@]} ${EXCLUDED_RULES[@]} --error --verbose || true
54+
else
55+
echo "Bad FAIL_ON_VULNERABILITIES env var value"
56+
exit 1
57+
fi
58+

docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
docreader:
55
image: regulaforensics/docreader:latest
66
volumes:
7-
- ./regula.license:/app/extBin/unix_x64/regula.license
7+
- ./regula.license:/app/extBin/unix_x64/regula.license
88
nginx:
99
image: nginx:alpine
1010
ports:
@@ -13,4 +13,4 @@ services:
1313
- ./conf/nginx.conf:/etc/nginx/nginx.conf
1414
- ./conf/.htpasswd:/etc/nginx/.htpasswd
1515
depends_on:
16-
- docreader
16+
- docreader

src/Regula.DocumentReader.NetCoreExample/Regula.DocumentReader.NetCoreExample.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<OutputType>Exe</OutputType>
44
<Product>DocumentReader WebClient Example</Product>
55
<PackageId>Regula.DocumentReader.NetCoreExampple</PackageId>
6-
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
6+
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
77
</PropertyGroup>
88
<ItemGroup>
99
<ProjectReference Include="..\Regula.DocumentReader.WebClient\Regula.DocumentReader.WebClient.csproj" />

src/Regula.DocumentReader.WebClient/Api/DocumentReaderApi.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ public RecognitionResponse Process(ProcessRequest processRequest, Dictionary<Str
5151
else
5252
processRequest.SystemInfo.License = License;
5353

54-
return new RecognitionResponse(this._processApi.ApiProcess(processRequest, headers, xRequestID));
54+
return new RecognitionResponse(this._processApi.ApiProcessWithHttpInfo(processRequest, headers, xRequestID));
5555
}
5656

57-
5857
public async Task<RecognitionResponse> ProcessAsync(ProcessRequest processRequest)
5958
{
6059
return await ProcessAsync(processRequest, new Dictionary<String, String>(), default(string));
@@ -77,7 +76,7 @@ public async Task<RecognitionResponse> ProcessAsync(ProcessRequest processReques
7776
else
7877
processRequest.SystemInfo.License = License;
7978

80-
var response = await this._processApi.ApiProcessAsync(processRequest, headers, xRequestID, cancellationToken);
79+
var response = await this._processApi.ApiProcessWithHttpInfoAsync(processRequest, headers, xRequestID, cancellationToken);
8180

8281
return new RecognitionResponse(response);
8382
}

src/Regula.DocumentReader.WebClient/Api/ProcessApi.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,11 @@ public void AddDefaultHeader(string key, string value)
258258
if (exception != null) throw exception;
259259
}
260260

261+
var rawResponse = localVarResponse.Content;
262+
261263
return new ApiResponse<ProcessResponse>(localVarStatusCode,
262264
localVarResponse.Headers.ToDictionarySafe(x => x.Name, x => string.Join(",", x.Value)),
263-
(ProcessResponse) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(ProcessResponse)));
265+
(ProcessResponse) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(ProcessResponse)), rawResponse);
264266
}
265267

266268
/// <summary>

src/Regula.DocumentReader.WebClient/Client/ApiResponse.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,30 @@ public class ApiResponse<T>
3535
/// </summary>
3636
/// <value>The data.</value>
3737
public T Data { get; private set; }
38+
39+
40+
/// <summary>
41+
/// Gets or sets the RawResponse
42+
/// </summary>
43+
/// <value>The data.</value>
44+
public string RawResponse { get; private set; }
3845

3946
/// <summary>
4047
/// Initializes a new instance of the <see cref="ApiResponse&lt;T&gt;" /> class.
4148
/// </summary>
4249
/// <param name="statusCode">HTTP status code.</param>
4350
/// <param name="headers">HTTP headers.</param>
4451
/// <param name="data">Data (parsed HTTP body)</param>
45-
public ApiResponse(int statusCode, IDictionary<string, string> headers, T data)
52+
/// <param name="rawResponse"></param>
53+
public ApiResponse(int statusCode,
54+
IDictionary<string, string> headers,
55+
T data,
56+
string rawResponse = null)
4657
{
4758
this.StatusCode= statusCode;
4859
this.Headers = headers;
4960
this.Data = data;
61+
this.RawResponse = rawResponse;
5062
}
5163

5264
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*
2+
* Regula Document Reader Web API
3+
*
4+
* 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
5+
*
6+
* The version of the OpenAPI document: 7.2.0
7+
*
8+
* Generated by: https://github.com/openapitools/openapi-generator.git
9+
*/
10+
11+
using System;
12+
using System.Linq;
13+
using System.IO;
14+
using System.Text;
15+
using System.Text.RegularExpressions;
16+
using System.Collections;
17+
using System.Collections.Generic;
18+
using System.Collections.ObjectModel;
19+
using System.Runtime.Serialization;
20+
using Newtonsoft.Json;
21+
using Newtonsoft.Json.Converters;
22+
using System.ComponentModel.DataAnnotations;
23+
using OpenAPIDateConverter = Regula.DocumentReader.WebClient.Client.OpenAPIDateConverter;
24+
25+
namespace Regula.DocumentReader.WebClient.Model
26+
{
27+
/// <summary>
28+
/// BinaryDataResult
29+
/// </summary>
30+
[DataContract]
31+
public partial class BinaryDataResult : IEquatable<BinaryDataResult>, IValidatableObject
32+
{
33+
/// <summary>
34+
/// Initializes a new instance of the <see cref="BinaryDataResult" /> class.
35+
/// </summary>
36+
/// <param name="nFields">Count of array fields.</param>
37+
/// <param name="pArrayFields">pArrayFields.</param>
38+
public BinaryDataResult(int nFields = default(int), List<TBinaryData> pArrayFields = default(List<TBinaryData>))
39+
{
40+
this.NFields = nFields;
41+
this.PArrayFields = pArrayFields;
42+
}
43+
44+
/// <summary>
45+
/// Count of array fields
46+
/// </summary>
47+
/// <value>Count of array fields</value>
48+
[DataMember(Name="nFields", EmitDefaultValue=false)]
49+
public int NFields { get; set; }
50+
51+
/// <summary>
52+
/// Gets or Sets PArrayFields
53+
/// </summary>
54+
[DataMember(Name="pArrayFields", EmitDefaultValue=false)]
55+
public List<TBinaryData> PArrayFields { get; set; }
56+
57+
/// <summary>
58+
/// Returns the string presentation of the object
59+
/// </summary>
60+
/// <returns>String presentation of the object</returns>
61+
public override string ToString()
62+
{
63+
var sb = new StringBuilder();
64+
sb.Append("class BinaryDataResult {\n");
65+
sb.Append(" NFields: ").Append(NFields).Append("\n");
66+
sb.Append(" PArrayFields: ").Append(PArrayFields).Append("\n");
67+
sb.Append("}\n");
68+
return sb.ToString();
69+
}
70+
71+
/// <summary>
72+
/// Returns the JSON string presentation of the object
73+
/// </summary>
74+
/// <returns>JSON string presentation of the object</returns>
75+
public virtual string ToJson()
76+
{
77+
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
78+
}
79+
80+
/// <summary>
81+
/// Returns true if objects are equal
82+
/// </summary>
83+
/// <param name="input">Object to be compared</param>
84+
/// <returns>Boolean</returns>
85+
public override bool Equals(object input)
86+
{
87+
return this.Equals(input as BinaryDataResult);
88+
}
89+
90+
/// <summary>
91+
/// Returns true if BinaryDataResult instances are equal
92+
/// </summary>
93+
/// <param name="input">Instance of BinaryDataResult to be compared</param>
94+
/// <returns>Boolean</returns>
95+
public bool Equals(BinaryDataResult input)
96+
{
97+
if (input == null)
98+
return false;
99+
100+
return
101+
(
102+
this.NFields == input.NFields ||
103+
(this.NFields != null &&
104+
this.NFields.Equals(input.NFields))
105+
) &&
106+
(
107+
this.PArrayFields == input.PArrayFields ||
108+
this.PArrayFields != null &&
109+
input.PArrayFields != null &&
110+
this.PArrayFields.SequenceEqual(input.PArrayFields)
111+
);
112+
}
113+
114+
/// <summary>
115+
/// Gets the hash code
116+
/// </summary>
117+
/// <returns>Hash code</returns>
118+
public override int GetHashCode()
119+
{
120+
unchecked // Overflow is fine, just wrap
121+
{
122+
int hashCode = 41;
123+
if (this.NFields != null)
124+
hashCode = hashCode * 59 + this.NFields.GetHashCode();
125+
if (this.PArrayFields != null)
126+
hashCode = hashCode * 59 + this.PArrayFields.GetHashCode();
127+
return hashCode;
128+
}
129+
}
130+
131+
/// <summary>
132+
/// To validate all properties of the instance
133+
/// </summary>
134+
/// <param name="validationContext">Validation context</param>
135+
/// <returns>Validation Result</returns>
136+
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
137+
{
138+
yield break;
139+
}
140+
}
141+
142+
}

src/Regula.DocumentReader.WebClient/Model/ContainerList.cs

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
* Regula Document Reader Web API
33
*
4-
* Regula Document Reader Web API
4+
* 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
55
*
6-
* The version of the OpenAPI document: 5.2.0
6+
* The version of the OpenAPI document: 7.2.0
77
*
88
* Generated by: https://github.com/openapitools/openapi-generator.git
99
*/
@@ -25,7 +25,7 @@
2525
namespace Regula.DocumentReader.WebClient.Model
2626
{
2727
/// <summary>
28-
/// list with result objects
28+
/// List with various objects, containing processing results
2929
/// </summary>
3030
[DataContract]
3131
public partial class ContainerList : IEquatable<ContainerList>, IValidatableObject
@@ -38,8 +38,9 @@ protected ContainerList() { }
3838
/// <summary>
3939
/// Initializes a new instance of the <see cref="ContainerList" /> class.
4040
/// </summary>
41+
/// <param name="count">Length of list (Count for items).</param>
4142
/// <param name="list">list (required).</param>
42-
public ContainerList(List<ResultItem> list = default(List<ResultItem>))
43+
public ContainerList(int count = default(int), List<ResultItem> list = default(List<ResultItem>))
4344
{
4445
// to ensure "list" is required (not null)
4546
if (list == null)
@@ -51,8 +52,16 @@ protected ContainerList() { }
5152
this.List = list;
5253
}
5354

55+
this.Count = count;
5456
}
5557

58+
/// <summary>
59+
/// Length of list (Count for items)
60+
/// </summary>
61+
/// <value>Length of list (Count for items)</value>
62+
[DataMember(Name="Count", EmitDefaultValue=false)]
63+
public int Count { get; set; }
64+
5665
/// <summary>
5766
/// Gets or Sets List
5867
/// </summary>
@@ -67,6 +76,7 @@ public override string ToString()
6776
{
6877
var sb = new StringBuilder();
6978
sb.Append("class ContainerList {\n");
79+
sb.Append(" Count: ").Append(Count).Append("\n");
7080
sb.Append(" List: ").Append(List).Append("\n");
7181
sb.Append("}\n");
7282
return sb.ToString();
@@ -78,7 +88,7 @@ public override string ToString()
7888
/// <returns>JSON string presentation of the object</returns>
7989
public virtual string ToJson()
8090
{
81-
return JsonConvert.SerializeObject(this, Formatting.Indented);
91+
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
8292
}
8393

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

104114
return
115+
(
116+
this.Count == input.Count ||
117+
(this.Count != null &&
118+
this.Count.Equals(input.Count))
119+
) &&
105120
(
106121
this.List == input.List ||
107122
this.List != null &&
@@ -119,6 +134,8 @@ public override int GetHashCode()
119134
unchecked // Overflow is fine, just wrap
120135
{
121136
int hashCode = 41;
137+
if (this.Count != null)
138+
hashCode = hashCode * 59 + this.Count.GetHashCode();
122139
if (this.List != null)
123140
hashCode = hashCode * 59 + this.List.GetHashCode();
124141
return hashCode;

0 commit comments

Comments
 (0)