Skip to content

Commit ed39141

Browse files
committed
Merge branch 'automatic-analyzer'
2 parents 3791804 + ed5b915 commit ed39141

File tree

7 files changed

+22
-1
lines changed

7 files changed

+22
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace SSLLWrapper.Models.Response.BaseSubModels
2+
{
3+
public class Wrapper
4+
{
5+
public int ApiPassCount { get; set; }
6+
public string ApiCommandUrl { get; set; }
7+
}
8+
}

SSLLabsApiWrapper/Domain/ResponsePopulation.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public Info InfoModel(WebResponseModel webResponse, Info infoModel)
2323

2424
infoModel = JsonConvert.DeserializeObject<Info>(webResponse.Payloay, JsonSerializerSettings);
2525
infoModel.Header = PopulateHeader(infoModel.Header, webResponse);
26+
infoModel.Wrapper.ApiCommandUrl = webResponse.Url;
2627

2728
return infoModel;
2829
}
@@ -31,6 +32,7 @@ public Analyze AnalyzeModel(WebResponseModel webResponse, Analyze analyzeModel)
3132
{
3233
analyzeModel = JsonConvert.DeserializeObject<Analyze>(webResponse.Payloay, JsonSerializerSettings);
3334
analyzeModel.Header = PopulateHeader(analyzeModel.Header, webResponse);
35+
analyzeModel.Wrapper.ApiCommandUrl = webResponse.Url;
3436

3537
if (analyzeModel.status == "ERROR") { analyzeModel.Errors.Add(new Error() { message = analyzeModel.statusMessage }); }
3638

@@ -41,6 +43,7 @@ public Endpoint EndpointModel(WebResponseModel webResponse, Endpoint endpointMod
4143
{
4244
endpointModel = JsonConvert.DeserializeObject<Endpoint>(webResponse.Payloay, JsonSerializerSettings);
4345
endpointModel.Header = PopulateHeader(endpointModel.Header, webResponse);
46+
endpointModel.Wrapper.ApiCommandUrl = webResponse.Url;
4447

4548
return endpointModel;
4649
}
@@ -49,6 +52,7 @@ public StatusCodes StatusCodesModel(WebResponseModel webResponse, StatusCodes st
4952
{
5053
statusCodes = JsonConvert.DeserializeObject<StatusCodes>(webResponse.Payloay, JsonSerializerSettings);
5154
statusCodes.Header = PopulateHeader(statusCodes.Header, webResponse);
55+
statusCodes.Wrapper.ApiCommandUrl = webResponse.Url;
5256

5357
return statusCodes;
5458
}

SSLLabsApiWrapper/External/SSLLabsApi.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public WebResponseModel MakeGetRequest(RequestModel requestModel)
2929
webResponseModel.Payloay = streamReader.ReadToEnd();
3030
webResponseModel.StatusCode = (int)response.StatusCode;
3131
webResponseModel.StatusDescription = response.StatusDescription;
32+
webResponseModel.Url = url;
3233

3334
return webResponseModel;
3435
}

SSLLabsApiWrapper/Interfaces/IBaseResponse.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ public interface IBaseResponse
88
Header Header { get; set; }
99
bool HasErrorOccurred { get; set; }
1010
List<Error> Errors { get; set; }
11+
Wrapper Wrapper { get; set; }
1112
}
1213
}

SSLLabsApiWrapper/Models/Response/BaseModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ public class BaseModel : IBaseResponse
99
public Header Header { get; set; }
1010
public bool HasErrorOccurred { get; set; }
1111
public List<Error> Errors { get; set; }
12+
public Wrapper Wrapper { get; set; }
1213

1314
public BaseModel()
1415
{
1516
Header = new Header();
1617
Errors = new List<Error>();
18+
Wrapper = new Wrapper();
1719
this.HasErrorOccurred = false;
1820
}
1921
}

SSLLabsApiWrapper/SSLLabsApiService.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ public Analyze AutomaticAnalyze(string host, int maxWaitInterval, int sleepInter
137137

138138
public Analyze AutomaticAnalyze(string host, Publish publish, ClearCache clearCache, FromCache fromCache, All all, int maxWaitInterval, int sleepInterval)
139139
{
140-
var startTime = DateTime.Now;
140+
var startTime = DateTime.Now;
141141
var sleepIntervalMilliseconds = sleepInterval * 1000;
142+
var apiPassCount = 1;
142143
var analyzeModel = Analyze(host, publish, clearCache, fromCache, all);
143144

144145
// Ignoring cache settings after first request to prevent loop
@@ -148,9 +149,12 @@ public Analyze AutomaticAnalyze(string host, Publish publish, ClearCache clearCa
148149
while (analyzeModel.HasErrorOccurred == false && analyzeModel.status != "READY" && (DateTime.Now - startTime).TotalSeconds < maxWaitInterval)
149150
{
150151
Thread.Sleep(sleepIntervalMilliseconds);
152+
apiPassCount ++;
151153
analyzeModel = Analyze(host, publish, clearCache, fromCache, all);
152154
}
153155

156+
analyzeModel.Wrapper.ApiPassCount = apiPassCount;
157+
154158
return analyzeModel;
155159
}
156160

SSLLabsApiWrapper/SSLLabsApiWrapper.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<ItemGroup>
4747
<Compile Include="External\SSLLabsApi.cs" />
4848
<Compile Include="Interfaces\IBaseResponse.cs" />
49+
<Compile Include="Models\Response\BaseSubModels\Wrapper.cs" />
4950
<Compile Include="Models\Response\StatusCodes.cs" />
5051
<Compile Include="Models\WebResponseModel.cs" />
5152
<Compile Include="SSLLabsApiService.cs" />

0 commit comments

Comments
 (0)