Skip to content

Commit ce546e6

Browse files
committed
7.0.8 release
7.0.8 release => [ENHANCEMENT] added referrer and content length to api trace 7.0.7 release => [ENHANCEMENT] check that restful, head and static statuscodes for return are valid
1 parent 49361d1 commit ce546e6

File tree

12 files changed

+106
-65
lines changed

12 files changed

+106
-65
lines changed

db/TD_API_TRACE.sql

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
[TRC_ERROR_PATH] VARCHAR(1024) NULL,
1616
[TRC_CORRELATION_ID] VARCHAR(1024) null,
1717
[TRC_JSONRPC_ERROR_CODE] int null,
18+
[TRC_CONTENT_LENGTH] BIGINT NULL,
19+
[TRC_REFERER] VARCHAR(MAX) NULL,
1820
PRIMARY KEY CLUSTERED ([TRC_ID] ASC)
1921
)
2022

@@ -107,4 +109,22 @@ EXEC sp_addextendedproperty @name = N'MS_Description',
107109
@level1type = N'TABLE',
108110
@level1name = N'TD_API_TRACE',
109111
@level2type = N'COLUMN',
110-
@level2name = N'TRC_JSONRPC_ERROR_CODE'
112+
@level2name = N'TRC_JSONRPC_ERROR_CODE'
113+
GO
114+
EXEC sp_addextendedproperty @name = N'MS_Description',
115+
@value = N'stores the referrer information',
116+
@level0type = N'SCHEMA',
117+
@level0name = N'dbo',
118+
@level1type = N'TABLE',
119+
@level1name = N'TD_API_TRACE',
120+
@level2type = N'COLUMN',
121+
@level2name = N'TRC_REFERER'
122+
GO
123+
EXEC sp_addextendedproperty @name = N'MS_Description',
124+
@value = N'stores the lenght of the request',
125+
@level0type = N'SCHEMA',
126+
@level0name = N'dbo',
127+
@level1type = N'TABLE',
128+
@level1name = N'TD_API_TRACE',
129+
@level2type = N'COLUMN',
130+
@level2name = N'TRC_CONTENT_LENGTH'

db/configuration/stored procedures/Security_Trace_Create.sql

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ Records Request information from the API
88
99
REVISION HISTORY
1010
----------------
11+
REVIEW NO. DATE CHANGED BY COMMENTS
12+
1 23/07/2024 Stephen Lane added content length and referrer
1113
1214
PEER REVIEW HISTORY
1315
-------------------
1416
REVIEW NO. DATE REVIEWED BY COMMENTS
1517
1618
*************************************************************************************/
17-
CREATE PROCEDURE Security_Trace_Create @TrcMethod NVARCHAR(256) = null
19+
CREATE or alter PROCEDURE Security_Trace_Create @TrcMethod NVARCHAR(256) = null
1820
,@TrcParams NVARCHAR(2048) = null
1921
,@TrcIp VARCHAR(15) = NULL
20-
,@TrcUseragent VARCHAR(2048)
22+
,@TrcUseragent VARCHAR(2048) = NULL
2123
,@Username NVARCHAR(256) = NULL
2224
,@TrcStartTime datetime
2325
,@TrcDuration decimal(18,3)
@@ -28,6 +30,8 @@ CREATE PROCEDURE Security_Trace_Create @TrcMethod NVARCHAR(256) = null
2830
,@TrcRequestType varchar(50) = null
2931
,@TrcCorrelationID varchar(1028)
3032
,@TrcJsonRpcErrorCode int =null
33+
,@TrcContentLength bigint =null
34+
,@TrcReferrer varchar(max) =null
3135
AS
3236
BEGIN
3337
SET NOCOUNT ON;
@@ -47,7 +51,9 @@ BEGIN
4751
,TRC_REQUEST_VERB
4852
,TRC_ERROR_PATH
4953
,TRC_CORRELATION_ID
50-
,TRC_JSONRPC_ERROR_CODE)
54+
,TRC_JSONRPC_ERROR_CODE
55+
,TRC_CONTENT_LENGTH
56+
,TRC_REFERER)
5157
VALUES (
5258
@TrcMethod
5359
,@TrcParams
@@ -64,6 +70,8 @@ BEGIN
6470
,@TrcErrorPath
6571
,@TrcCorrelationID
6672
,@TrcJsonRpcErrorCode
73+
,@TrcContentLength
74+
,@TrcReferrer
6775
)
6876

6977
RETURN 1

rls/appsettings.json

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
{
22
"Blocked_Requests": null,
33
"API_Config": {
4-
"version": null,
4+
"version": 1.0,
55
"API_MAINTENANCE": false,
6-
"distributed_config": true,
7-
"Settings_Type": "DB"
6+
"Settings_Type": "JSONFile"
87
},
98
"APP_Config": {
109
"enabled": true,
1110
"version": 1.0,
1211
"Settings_Type": "JSONFile", //JSONFile - DB
12+
"auto_version": false,
1313
"distributed_config": false
1414
},
1515
"Logging": {
1616
"LogLevel": {
1717
"Default": "Information",
1818
"Microsoft.AspNetCore": "Warning"
1919
}
20+
2021
},
2122
"Log4NetCore": {
2223
"Log4NetConfigFileName": "log4net.config"
@@ -41,39 +42,16 @@
4142
"ADOSettings": {
4243
"API_ADO_DEFAULT_CONNECTION": "DefaultConnection",
4344
"API_PERFORMANCE_DATABASE": "DefaultConnection",
44-
"API_TRACE_DATABASE": "DefaultConnection",
4545
"API_ADO_EXECUTION_TIMEOUT": 3600,
4646
"API_ADO_BULKCOPY_TIMEOUT": 3600,
47-
"API_ADO_BULKCOPY_BATCHSIZE": 4999,
48-
"API_DATABASE_TRACE_ENABLED": true
49-
},
50-
"APIPerformanceSettings": {
51-
"API_PERFORMANCE_ENABLED": false
52-
},
53-
"CacheSettings": {
54-
"API_MEMCACHED_SALSA": "",
55-
"API_MEMCACHED_MAX_VALIDITY": "2592000",
56-
"API_MEMCACHED_MAX_SIZE": "128",
57-
"API_MEMCACHED_ENABLED": false,
58-
"API_CACHE_TRACE_ENABLED": false
47+
"API_ADO_BULKCOPY_BATCHSIZE": 4999
5948
},
6049
"enyimMemcached": {
6150
"Servers": [
6251
{
6352
"Address": "",
6453
"Port": 11211
6554
}
66-
],
67-
"socketPool": {
68-
"minPoolSize": "1",
69-
"maxPoolSize": "10",
70-
"connectionTimeout": "00:00:15",
71-
"receiveTimeout": "00:00:15",
72-
"deadTimeout": "00:00:15",
73-
"queueTimeout": "00:00:00.15",
74-
"InitPoolTimeout": "00:00:15"
75-
},
76-
"SuppressException": false,
77-
"UseSslStream": false
55+
]
7856
}
7957
}

rls/packages/API.Library.7.0.7.nupkg

66.8 KB
Binary file not shown.

rls/packages/API.Library.7.0.8.nupkg

67.1 KB
Binary file not shown.

src/API.Library/API.Library.csproj

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,12 @@
1212
<PackageId>API.Library</PackageId>
1313
<Product>API Library</Product>
1414
<Copyright>Central Statistics Office, Ireland</Copyright>
15-
<Version>7.0.6</Version>
15+
<Version>7.0.8</Version>
1616
<Authors>Central Statistics Office, Ireland</Authors>
1717
<SignAssembly>False</SignAssembly>
1818
<RepositoryUrl>https://github.com/CSOIreland/Server-API-Library</RepositoryUrl>
1919
<PackageReleaseNotes>
20-
- [BUG FIX] trace method and params not being recorded if cache trace disable
21-
- [ENHANCEMENT] changed when trace gets its correlationID
22-
- [ENHANCEMENT] removed threadAbortException as performance thread abort is handled in its own try catch. removed from middleware,static, jsonrpc and RESTful
23-
- [BUG FIX] added try catch around dictionary tryadd function use
24-
- [ENHANCEMENT] improved logging for jsonrpc and restful requests
25-
- [BUG FIX] returnResponseAsync now raises OperationCanceledException rather than TaskCanceledException
26-
- [ENHANCEMENT] wrap performance thread creation in existing try catch block
27-
- [BUG FIX] change from sending e.message to "Bad Request" in restful and static exception response
20+
- [ENHANCEMENT] added referrer and content length to api trace
2821
</PackageReleaseNotes>
2922
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
3023
<RestoreLockedMode>true</RestoreLockedMode>

src/API.Library/Entities/API.RESTful.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,12 @@ public async Task ProcessRequest(HttpContext httpContext, CancellationTokenSourc
107107
{
108108
await ParseError(httpContext, HttpStatusCode.InternalServerError, apiCancellationToken, "Internal Error");
109109
}
110+
else if (!Utility.IsValidStatusCode((int)result.statusCode))
111+
{
112+
await ParseError(httpContext, HttpStatusCode.InternalServerError, apiCancellationToken, "Internal Error");
113+
}
110114
else
111115
{
112-
113116
if (httpContext.Request.Method == "HEAD")
114117
{
115118

src/API.Library/Entities/API.Static.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ public async Task ProcessRequest(HttpContext httpContext, CancellationTokenSourc
7171
{
7272
await ParseError(httpContext, HttpStatusCode.InternalServerError, apiCancellationToken, "Internal Error");
7373
}
74+
else if (!Utility.IsValidStatusCode((int)result.statusCode))
75+
{
76+
await ParseError(httpContext, HttpStatusCode.InternalServerError, apiCancellationToken, "Internal Error");
77+
}
7478
else if (result.statusCode == HttpStatusCode.OK)
7579
{
7680

src/API.Library/Entities/Tracing/Trace/Trace_ADO.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,21 @@ internal static void Create(Trace trace)
2424
Log.Instance.Info("Trace information : " + Utility.JsonSerialize_IgnoreLoopingReference(trace));
2525
List<ADO_inputParams> inputParamList = new List<ADO_inputParams>()
2626
{
27-
new ADO_inputParams() {name= "@TrcUseragent",value=trace.TrcUseragent},
2827
new ADO_inputParams() {name= "@TrcStartTime",value=trace.TrcStartTime},
2928
new ADO_inputParams() {name= "@TrcDuration",value=trace.TrcDuration},
3029
new ADO_inputParams() {name= "@TrcStatusCode",value=trace.TrcStatusCode},
3130
new ADO_inputParams() {name= "@TrcMachineName",value=trace.TrcMachineName},
3231
new ADO_inputParams() {name= "@TrcRequestVerb", value = trace.TrcRequestVerb},
3332
new ADO_inputParams() {name= "@TrcCorrelationID", value = trace.TrcCorrelationID},
33+
new ADO_inputParams() {name= "@TrcContentLength", value = trace.TrcContentLength}
3434
};
3535

36+
if (!string.IsNullOrEmpty(trace.TrcUseragent))
37+
inputParamList.Add(new ADO_inputParams() { name = "@TrcUseragent", value = trace.TrcUseragent });
38+
39+
if (!string.IsNullOrEmpty(trace.TrcReferrer))
40+
inputParamList.Add(new ADO_inputParams() { name = "@TrcReferrer", value = trace.TrcReferrer });
41+
3642
if (!string.IsNullOrEmpty(trace.TrcRequestType))
3743
inputParamList.Add(new ADO_inputParams() { name = "@TrcRequestType", value = trace.TrcRequestType });
3844

src/API.Library/Entities/Tracing/Trace/Trace_DTO.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,24 @@ public class Trace
7373
public string TrcCorrelationID { get; set; }
7474

7575
/// <summary>
76-
/// request josn rpc error code
76+
/// request json rpc error code
7777
/// </summary>
7878
public int? TrcJsonRpcErrorCode { get; set; }
79+
80+
81+
/// <summary>
82+
/// request referrer
83+
/// </summary>
84+
public string TrcReferrer { get; set; }
85+
86+
87+
/// <summary>
88+
/// request content length
89+
/// </summary>
90+
public long? TrcContentLength { get; set; }
91+
7992
#endregion
93+
94+
8095
}
8196
}

0 commit comments

Comments
 (0)