Skip to content

Commit

Permalink
Merge pull request #53 from odedshimon/upgrade-ci-multi-platform-buil…
Browse files Browse the repository at this point in the history
…d-and-test

upgraded ci to test and build on multi platforms
  • Loading branch information
odedshimon authored Jan 2, 2021
2 parents a73e94e + 55c8b3a commit 750571d
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 35 deletions.
45 changes: 35 additions & 10 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,49 @@ on:
jobs:
build:

runs-on: windows-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
dotnet-version: [3.1.301]
tests-paths: [./BruteShark/PcapAnalyzerTest, ./BruteShark/PcapProcessorTest]
os: [macOS-latest, ubuntu-latest, windows-latest]
exclude:
- os: windows-latest
tests-paths: ./BruteShark/PcapProcessorTest

include:
- os: macOS-latest
projects-paths: ./BruteShark/BruteSharkCli
test-flag: --no-build
build-flag: ""

- os: ubuntu-latest
projects-paths: ./BruteShark/BruteSharkCli
test-flag: --no-build
build-flag: ""

- os: windows-latest
projects-paths: ./BruteShark
test-flag: ""
build-flag: --no-restore

steps:
- uses: actions/checkout@v2

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
dotnet-version: ${{ matrix.dotnet-version }}

- name: Install dependencies
run: dotnet restore
working-directory: ./BruteShark
working-directory: ${{ matrix.projects-paths }}

- name: Test
run: dotnet test --verbosity normal
working-directory: ./BruteShark/PcapAnalyzerTest
run: dotnet test --verbosity normal ${{ matrix.test-flag }}
working-directory: ${{ matrix.tests-paths }}

- name: Build
run: dotnet build --configuration Release --no-restore
working-directory: ./BruteShark
run: dotnet build --configuration Release ${{ matrix.build-flag }}
working-directory: ${{ matrix.projects-paths }}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ namespace PcapAnalyzer
{
public class FtpPasswordParser : IPasswordParser
{
private Regex _ftpSuccessfullLoginRegex = new Regex(@"220(.*)\r\nUSER\s(?<Username>.*)\r\n331(.*)\r\nPASS\s(?<Password>.*)\r\n");

private Regex ftpSuccessfullLoginRegex = new Regex(@"220(.*)[\r\n]+USER\s(?<Username>.*)[\r\n]+331(.*)[\r\n]+PASS\s(?<Password>.*)[\r\n]+");
public NetworkLayerObject Parse(UdpPacket udpPacket) => null;

public NetworkLayerObject Parse(TcpPacket tcpPacket) => null;
Expand All @@ -18,7 +17,7 @@ public NetworkLayerObject Parse(TcpSession tcpSession)
NetworkPassword credential = null;
var sessionData = Encoding.UTF8.GetString(tcpSession.Data);

Match match = this._ftpSuccessfullLoginRegex.Match(sessionData);
Match match = this.ftpSuccessfullLoginRegex.Match(sessionData);

if (match.Success)
{
Expand All @@ -30,6 +29,16 @@ public NetworkLayerObject Parse(TcpSession tcpSession)
Source = tcpSession.SourceIp,
Destination = tcpSession.DestinationIp
};

if(credential.Password.EndsWith("\r"))
{
credential.Password = credential.Password.Replace("\r", "");
}

if (credential.Username.EndsWith("\r"))
{
credential.Username = credential.Username.Replace("\r", "");
}
}

return credential;
Expand Down
11 changes: 10 additions & 1 deletion BruteShark/PcapAnalyzerTest/NetworkMapModuleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@ public void NetworkMapAsJsonString_Test()
}
};

var expectedJson = File.ReadAllText(this.NetworkConnectionsListJson);

string expectedJson = @"[
{
""Source"": ""1.1.1.1"",
""Destination"": ""2.2.2.2"",
""Protocol"": ""TCP"",
""SrcPort"": 3009,
""DestPort"": 80
}
]";

// Act.
string jsonString = PcapAnalyzer.NetwrokMapJsonExporter.GetNetworkMapAsJsonString(connections);
Expand Down
11 changes: 0 additions & 11 deletions BruteShark/PcapAnalyzerTest/PcapAnalyzerTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,4 @@
<ProjectReference Include="..\PcapAnalyzer\PcapAnalyzer.csproj" />
</ItemGroup>


<ItemGroup>
<EmbeddedResource Include="TestFiles\*.json" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="TestFiles\*.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>

</Project>

This file was deleted.

2 changes: 1 addition & 1 deletion BruteShark/PcapProcessorTest/PcapProcessorTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
Expand Down

0 comments on commit 750571d

Please sign in to comment.