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

Add License Compliance Workflow #134

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/license-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: License Compliance Check
# UNCOMMENT TO ENABLE THE WORKFLOW
# on:
# push:
# branches:
# - "**"
# paths-ignore:
# - "k8s/**"
# - "**/*.md"
jobs:
license-check:
runs-on: ubuntu-latest
steps:

# SETUP DEVELOPMENT ENVIRONMENT FOR THE LANGUAGE OF THE REPOSITORY
# this should be similar to the setup for tests

###############################################################
# - name: Checkout and setup go for private repositories
# uses: whalebone/github-actions-go/checkout-setup@v1
# with:
# go-version-file: "go.mod"
# GH_USERNAME: ${{ secrets.GH_USERNAME }}
# GH_TOKEN: ${{ secrets.GH_TOKEN }}
###############################################################
- name: Run License Compliance Check
uses: whalebone/license-compliance@v1
with:
licenses_group: 'cloud' # 'cloud' or 'onprem' at the moment
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ if test "$with_ldns_libraries" != "no"; then
LDFLAGS="${LDFLAGS} -L${with_ldns_libraries}"
fi

LDFLAGS="${LDFLAGS} -lldns"
LDFLAGS="${LDFLAGS} -lldns -lssl -lcrypto"

# Check or ldns headers
AC_CHECK_HEADER(ldns/ldns.h,,LIBLDNS_H="no")
Expand Down
48 changes: 47 additions & 1 deletion src/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#include "passivedns.h"
#include "dns.h"

#include <openssl/sha.h>
#include <math.h>

#ifdef HAVE_JSON
#include <jansson.h>
#endif /* HAVE_JSON */
Expand All @@ -42,6 +45,8 @@ extern globalconfig config;
#define DBUCKET_SIZE 3967 /* Carol that is primes */

pdns_record *dbucket[DBUCKET_SIZE];
char hash_datestamp[200];
char hash_datesha256[65];

uint64_t hash(unsigned char *str)
{
Expand Down Expand Up @@ -644,6 +649,44 @@ const char *u_ntop(const struct in6_addr ip_addr, int af, char *dest)
return dest;
}

void sha256(char *string, char salt[65], char outputBuffer[65])
{
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256;
SHA256_Init(&sha256);
if (strlen(salt) > 0)
{
SHA256_Update(&sha256, salt, strlen(salt));
}
SHA256_Update(&sha256, string, strlen(string));
SHA256_Final(hash, &sha256);
int i = 0;
for(i = 0; i < SHA256_DIGEST_LENGTH; i++)
{
sprintf(outputBuffer + (i * 2), "%02x", hash[i]);
}
outputBuffer[64] = 0;
}

void sha256_string(pdns_record *l, char *string, char outputBuffer[65])
{
struct tm *tmpTime;
char timestr[200];
char timebuf[200];
tmpTime = localtime(&l->last_seen.tv_sec);
strftime(timestr, sizeof(timestr), "%Y-%U", tmpTime);
if (strcmp(timestr, hash_datestamp) != 0)
{
strcpy(hash_datestamp, timestr);
strftime(timebuf, sizeof(timestr), "%U %Y-%m-%d %H:%M:%S", tmpTime);
sprintf(timestr, "%s.%03d\n", timebuf, l->last_seen.tv_usec);
sha256(timestr, "", hash_datesha256);
//printf("** %s -- %s\n", timestr, hash_datesha256);
}

sha256(string, hash_datesha256, outputBuffer);
}

void print_passet(pdns_record *l, pdns_asset *p, ldns_rr *rr,
ldns_rdf *lname, uint16_t rcode)
{
Expand Down Expand Up @@ -1067,7 +1110,10 @@ void print_passet(pdns_record *l, pdns_asset *p, ldns_rr *rr,
if (config.fieldsf & FIELD_CLIENT) {
if (offset != 0)
offset += snprintf(output+offset, sizeof(buffer) - offset, "%s", d);
offset += snprintf(output+offset, sizeof(buffer) - offset, "%s", ip_addr_c);

unsigned char shahash[65];
sha256_string(l, ip_addr_c, shahash);
offset += snprintf(output+offset, sizeof(buffer) - offset, "%s", shahash);
}

/* Print client hardware address */
Expand Down