Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unittest to display issue #920. #512

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/detect-engine-address.c
Original file line number Diff line number Diff line change
Expand Up @@ -2298,6 +2298,48 @@ int AddressTestParse37(void)
return 0;
}

int AddressTestParse38(void)
{
int result = 0;

char *addr1 = "[192.168.0.0/16, 10.0.0.0/8,172.16.0.0/12]";
char *addr2 = "[10.10.10.0/24, !10.10.10.247]";
char *addr3 = "[10.10.10.0/24, !10.10.10.247/32]";

DetectAddressHead *gh;
int r;

gh = DetectAddressHeadInit();
if (gh == NULL)
goto end;
r = DetectAddressParse(gh, addr1);
if (r < 0)
goto end;
DetectAddressHeadFree(gh);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think it would be a good idea to also check that the internal state is correct.


gh = DetectAddressHeadInit();
if (gh == NULL)
goto end;
r = DetectAddressParse(gh, addr2);
if (r < 0)
goto end;
DetectAddressHeadFree(gh);

gh = DetectAddressHeadInit();
if (gh == NULL)
goto end;
r = DetectAddressParse(gh, addr3);
if (r < 0)
goto end;
DetectAddressHeadFree(gh);

result = 1;

end:
return result;
}

int AddressTestMatch01(void)
{
DetectAddress *dd = NULL;
Expand Down Expand Up @@ -4761,6 +4803,7 @@ void DetectAddressTests(void)
UtRegisterTest("AddressTestParse35", AddressTestParse35, 1);
UtRegisterTest("AddressTestParse36", AddressTestParse36, 1);
UtRegisterTest("AddressTestParse37", AddressTestParse37, 1);
UtRegisterTest("AddressTestParse38", AddressTestParse38, 1);

UtRegisterTest("AddressTestMatch01", AddressTestMatch01, 1);
UtRegisterTest("AddressTestMatch02", AddressTestMatch02, 1);
Expand Down