Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
bb9d7f9
feat(licenseText): update license texts from SPDX
shaheemazmalmmd Jul 29, 2021
f42e073
feat(monk): New delimiters dnl
GMishx Aug 5, 2021
5f06960
feat(monkbulk): Custom delimters
GMishx Aug 6, 2021
9b474be
feat(ui): Read delimiters for clean text
GMishx Aug 19, 2021
a3c9290
hotfix(api): Add missing auth controller
GMishx Aug 30, 2021
6d7bd7f
Merge pull request #2094 from siemens/fix/api/add-authcontroller
shaheemazmalmmd Sep 1, 2021
0d52279
docs: Updated README.md and CONTRIBUTING.md
Piyussshh Apr 2, 2021
f7fda9d
Merge pull request #2099 from fossology/Piyussshh-master
ag4ums Sep 2, 2021
b3d8b47
feat(unifiedreport): include assigned to in component clearing section
shaheemazmalmmd Sep 1, 2021
edd4955
Merge pull request #2069 from siemens/contrib/licenseTextUpates
ag4ums Sep 17, 2021
7c42552
Merge pull request #2096 from siemens/feat/assignedToReport
ag4ums Sep 17, 2021
50b3bf1
feat(rest): Update upload information
GMishx Sep 22, 2021
4a97810
fix(upload): Fix upload description input
GMishx Sep 27, 2021
5573665
Merge pull request #2102 from siemens/fix/upload/upload-description
ag4ums Sep 27, 2021
3d71a2c
feat(os): Support Debian 11
GMishx Oct 4, 2021
357f068
Merge pull request #2106 from siemens/feat/os/debian-11
ag4ums Oct 19, 2021
4d855cf
Merge pull request #2073 from siemens/feat/monkbulk/clean-text
ag4ums Oct 20, 2021
14394ec
Merge pull request #2101 from siemens/feat/rest/update-upload-info
shaheemazmalmmd Oct 26, 2021
31dd1c4
feat(ci): GitHub-ci for c-tests
ag4ums Aug 24, 2021
6c241d2
fix(test): Fix licenseRef.json
GMishx Oct 28, 2021
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
1 change: 1 addition & 0 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
os:
- 'debian:buster'
- 'debian:stretch'
- 'debian:bullseye'
- 'ubuntu:bionic'
- 'ubuntu:focal'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
run: |
composer install --prefer-dist --working-dir=src
src/vendor/bin/phpcs --standard=src/fossy-ruleset.xml -p

copy-paste:
runs-on: ubuntu-20.04
continue-on-error: true
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/test-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright 2021 Anupam Ghosh <[email protected]>,
# Gaurav Mishra <[email protected]>
# SPDX-License-Identifier: GPL-2.0 AND LGPL-2.1

name: c tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
C-tests:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
php: ['7.4'] # Can be extended in future
services:
postgres:
image: postgres:12
env:
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 50

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libcppunit-dev
sudo ./utils/fo-installdeps -y -e
export PATH="/usr/lib/ccache/:$PATH"

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, gd, xml, zip, json, sqlite3, curl
env:
fail-fast: true

- name: Setup test database
env:
PGHOST: 127.0.0.1
PGPORT: 5432
run: |
./utils/prepare-test -afty

#remove test all as delagent is failing
- name: Unit tests
env:
PGHOST: 127.0.0.1
PGPORT: 5432
run: |
make all phpvendors test-cli test-copyright test-lib test-monk \
test-nomos test-ojo test-reuser test-scheduler test-spdx2 \
test-unifiedreport test-www
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ The cardinal rule for creating good commits is to ensure there is only one
code changes entangled with the original commit.

- When troubleshooting problems using Git's bisect capability, small well
defined changes will aid in isolating exactly where the code problem was
-defined changes will aid in isolating exactly where the code problem was
introduced.

- When browsing history using Git annotate/blame, small well defined changes
- When browsing history using Git annotate/blame, small well-defined changes
also aid in isolating exactly where & why a piece of code came from.

Things to avoid when creating commits
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

## About

FOSSology is an open source license compliance software system and toolkit. As a toolkit, you can run license, copyright and export control scans from the command line. As a system, a database and web UI are provided to give you a compliance workflow. In one click you can generate an SPDX file or a ReadMe with all the copyrights notices from your software. FOSSology deduplication means that you can scan an entire distro, rescan a new version, and only the changed files will get rescanned. This is a big time saver for large projects.
FOSSology is an open source license compliance software system and toolkit. As a toolkit, you can run license, copyright, and export control scans from the command line. As a system, a database and web UI are provided to give you a compliance workflow. In one click you can generate an SPDX file or a ReadMe with all the copyrights notices from your software. FOSSology deduplication means that you can scan an entire distro, rescan a new version, and only the changed files will get rescanned. This is a big time saver for large projects.

[Check out Who Uses FOSSology!](https://www.fossology.org)

Expand Down Expand Up @@ -98,7 +98,7 @@ and developer docs on [Github Wiki](https://github.com/fossology/fossology/wiki)

## Support

Mailing lists, FAQs, Release Notes, and other useful info is available
Mailing lists, FAQs, Release Notes, and other useful info are available
by clicking the documentation tab on the project website. We encourage
all users to join the mailing list and participate in discussions.
There is also a #fossology IRC channel on the freenode IRC network if
Expand Down
1,366 changes: 914 additions & 452 deletions install/db/licenseRef.json

Large diffs are not rendered by default.

49 changes: 39 additions & 10 deletions src/cli/exportLicenseRefUsingSPDX.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/***********************************************************
Copyright (C) 2019 Siemens AG
Copyright (C) 2019,2021 Siemens AG

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -42,6 +42,10 @@ function startProcessingLicenseData()
$updateExisting = '';
$addNewLicense = '';
$newLicenseRefData = array();
$scanList = array(
'licenses' => 'https://spdx.org/licenses/licenses.json',
'exceptions' => 'https://spdx.org/licenses/exceptions.json'
);
$usage = "Usage: " . basename($argv[0]) . " [options]

Create new licenseref.json file. Options are:
Expand All @@ -64,10 +68,6 @@ function startProcessingLicenseData()
For type 'licenses' URL is : $scanList[licenses]

For type 'exceptions' URL is : $scanList[exceptions]";
$scanList = array(
'licenses' => 'https://spdx.org/licenses/licenses.json',
'exceptions' => 'https://spdx.org/licenses/exceptions.json'
);

$options = getopt("hcEen", array("type:","url:"));
/* get type and url if exists if not set them to empty */
Expand Down Expand Up @@ -203,10 +203,10 @@ function getListSPDX($type, $URL, $updateWithNew, $updateExisting, $addNewLicens
!empty($updateExisting)
)
) {
$existingLicenseRefData[$licenseIdCheck]['rf_fullname'] = $getCurrentData[$this->mapArrayData[$type][2]];
$existingLicenseRefData[$licenseIdCheck]['rf_text'] = $getCurrentData[$this->mapArrayData[$type][1]];
$existingLicenseRefData[$licenseIdCheck]['rf_fullname'] = $this->replaceUnicode($getCurrentData[$this->mapArrayData[$type][2]]);
$existingLicenseRefData[$licenseIdCheck]['rf_text'] = $this->replaceUnicode($getCurrentData[$this->mapArrayData[$type][1]]);
$existingLicenseRefData[$licenseIdCheck]['rf_url'] = $getCurrentData['seeAlso'][0];
$existingLicenseRefData[$licenseIdCheck]['rf_notes'] = (array_key_exists("licenseComments", $getCurrentData) ? $getCurrentData['licenseComments'] : $existingLicenseRefData[$licenseIdCheck]['rf_notes']);
$existingLicenseRefData[$licenseIdCheck]['rf_notes'] = $this->replaceUnicode((array_key_exists("licenseComments", $getCurrentData) ? $getCurrentData['licenseComments'] : $existingLicenseRefData[$licenseIdCheck]['rf_notes']));
echo "INFO: license ".$getCurrentData[$this->mapArrayData[$type][0]]." updated\n\n";
}
if (!is_numeric($licenseIdCheck) &&
Expand All @@ -218,7 +218,7 @@ function getListSPDX($type, $URL, $updateWithNew, $updateExisting, $addNewLicens
) {
$existingLicenseRefData[] = array(
'rf_shortname' => $getCurrentData[$this->mapArrayData[$type][0]],
'rf_text' => $getCurrentData[$this->mapArrayData[$type][1]],
'rf_text' => $this->replaceUnicode($getCurrentData[$this->mapArrayData[$type][1]]),
'rf_url' => $getCurrentData['seeAlso'][0],
'rf_add_date' => null,
'rf_copyleft' => null,
Expand All @@ -227,7 +227,7 @@ function getListSPDX($type, $URL, $updateWithNew, $updateExisting, $addNewLicens
'rf_FSFfree' => null,
'rf_GPLv2compatible' => null,
'rf_GPLv3compatible' => null,
'rf_notes' => (array_key_exists("licenseComments", $getCurrentData) ? $getCurrentData['licenseComments'] : null),
'rf_notes' => $this->replaceUnicode((array_key_exists("licenseComments", $getCurrentData) ? $getCurrentData['licenseComments'] : null)),
'rf_Fedora' => null,
'marydone' => "f",
'rf_active' => "t",
Expand All @@ -243,6 +243,35 @@ function getListSPDX($type, $URL, $updateWithNew, $updateExisting, $addNewLicens
}
return $existingLicenseRefData;
}

/**
* Replace common unicode characters with ASCII for consistent results.
*
* @param string $text Input text
* @return string Input with characters replaced
*/
private function replaceUnicode($text)
{
$search = [
'\u00a0', // no break space
'\u2018', // Left single quote
'\u2019', // Right single quote
'\u201c', // Left double quote
'\u201d', // Right double quote
'\u2013', // em dash
];

$replace = [
" ",
"'",
"'",
'"',
'"',
"-",
];

return str_replace($search, $replace, $text);
}
}
$obj = new exportLicenseRef();
echo $obj->startProcessingLicenseData();
4 changes: 3 additions & 1 deletion src/copyright/mod_deps
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ if [[ $RUNTIME ]]; then
case "$CODENAME" in
stretch)
apt-get $YesOpt install libjsoncpp1 libboost-filesystem1.62.0;;
buster|sid)
buster)
apt-get $YesOpt install libjsoncpp1 libboost-filesystem1.67.0;;
bullseye|sid)
apt-get $YesOpt install libjsoncpp24 libboost-filesystem1.74.0;;
bionic)
apt-get $YesOpt install libjsoncpp1 libboost-filesystem1.65.1;;
focal)
Expand Down
4 changes: 2 additions & 2 deletions src/decider/agent/BulkReuser.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public function rerunBulkAndDeciderOnUpload($uploadId, $groupId, $userId, $bulkI
*/
$deciderPlugin = plugin_find("agent_deciderjob");
$dependecies = array();
$sql = "INSERT INTO license_ref_bulk (user_fk,group_fk,rf_text,upload_fk,uploadtree_fk,ignore_irrelevant) "
. "SELECT $1 AS user_fk, $2 AS group_fk,rf_text,$3 AS upload_fk, $4 as uploadtree_fk, ignore_irrelevant
$sql = "INSERT INTO license_ref_bulk (user_fk,group_fk,rf_text,upload_fk,uploadtree_fk,ignore_irrelevant,bulk_delimiters) "
. "SELECT $1 AS user_fk, $2 AS group_fk,rf_text,$3 AS upload_fk, $4 as uploadtree_fk, ignore_irrelevant, bulk_delimiters
FROM license_ref_bulk WHERE lrb_pk=$5 RETURNING lrb_pk, $5 as lrb_origin";
$sqlLic = "INSERT INTO license_set_bulk (lrb_fk, rf_fk, removing, comment, reportinfo, acknowledgement) "
."SELECT $1 as lrb_fk, rf_fk, removing, comment, reportinfo, acknowledgement FROM license_set_bulk WHERE lrb_fk=$2";
Expand Down
16 changes: 12 additions & 4 deletions src/lib/php/Dao/LicenseDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,16 +551,24 @@ public function getLicenseByShortName($licenseShortname, $groupId=null)
* @param bool[] $licenseRemovals
* @param string $refText
* @param bool $ignoreIrrelevant Ignore irrelevant files while scanning
* @param string $delimiters Delimiters for bulk scan,
* null or "DEFAULT" for default values
* @return int lrp_pk on success or -1 on fail
*/
public function insertBulkLicense($userId, $groupId, $uploadTreeId, $licenseRemovals, $refText, $ignoreIrrelevant=true)
public function insertBulkLicense($userId, $groupId, $uploadTreeId, $licenseRemovals, $refText, $ignoreIrrelevant=true, $delimiters=null)
{
if (strcasecmp($delimiters, "DEFAULT") === 0) {
$delimiters = null;
} elseif ($delimiters !== null) {
$delimiters = StringOperation::replaceUnicodeControlChar($delimiters);
}
$licenseRefBulkIdResult = $this->dbManager->getSingleRow(
"INSERT INTO license_ref_bulk (user_fk, group_fk, uploadtree_fk, rf_text, ignore_irrelevant)
VALUES ($1,$2,$3,$4,$5) RETURNING lrb_pk",
"INSERT INTO license_ref_bulk (user_fk, group_fk, uploadtree_fk, rf_text, ignore_irrelevant, bulk_delimiters)
VALUES ($1,$2,$3,$4,$5,$6) RETURNING lrb_pk",
array($userId, $groupId, $uploadTreeId,
StringOperation::replaceUnicodeControlChar($refText),
$this->dbManager->booleanToDb($ignoreIrrelevant)),
$this->dbManager->booleanToDb($ignoreIrrelevant),
$delimiters),
__METHOD__ . '.getLrb'
);
if ($licenseRefBulkIdResult === false) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/php/UI/template/include/upload.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<li>
<div class="form-group">
<label for="{{ fileInputName }}">({{ 'Optional'|trans }}) {{ 'Enter a description of this file'| trans }}:</label>
<input type="text" class="form-control" style="width:40%;" name="{{ descriptionInputName }} value="{{ descriptionInputValue }}">
<input type="text" class="form-control" style="width:40%;" name="{{ descriptionInputName }}" value="{{ descriptionInputValue }}">
</div>
</li>
<li>
Expand Down
6 changes: 3 additions & 3 deletions src/monk/agent/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ static char* getFileName(MonkState* state, long pFileId) {
return pFileName;
}

int matchPFileWithLicenses(MonkState* state, long pFileId, const Licenses* licenses, const MatchCallbacks* callbacks) {
int matchPFileWithLicenses(MonkState* state, long pFileId, const Licenses* licenses, const MatchCallbacks* callbacks, char* delimiters) {
File file;
file.id = pFileId;
int result = 0;

file.fileName = getFileName(state, pFileId);

if (file.fileName != NULL) {
result = readTokensFromFile(file.fileName, &(file.tokens), DELIMITERS);
result = readTokensFromFile(file.fileName, &(file.tokens), delimiters);

if (result) {
result = matchFileWithLicenses(state, &file, licenses, callbacks);
Expand Down
2 changes: 1 addition & 1 deletion src/monk/agent/match.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ size_t match_getEnd(const Match* match);

GArray* findAllMatchesBetween(const File* file, const Licenses* licenses, unsigned maxAllowedDiff, unsigned minAdjacentMatches, unsigned maxLeadingDiff);

int matchPFileWithLicenses(MonkState* state, long pFileId, const Licenses* licenses, const MatchCallbacks* callbacks);
int matchPFileWithLicenses(MonkState* state, long pFileId, const Licenses* licenses, const MatchCallbacks* callbacks, char* delimiters);
int matchFileWithLicenses(MonkState* state, const File* file, const Licenses* licenses, const MatchCallbacks* callbacks);

void findDiffMatches(const File* file, const License* license,
Expand Down
2 changes: 1 addition & 1 deletion src/monk/agent/monk.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define DIFF_TYPE_REMOVAL "M-"
#define DIFF_TYPE_REPLACE "MR"

#define DELIMITERS " \t\n\r\f#^%"
#define DELIMITERS " \t\n\r\f#^%,*"

#define MONK_CASE_INSENSITIVE
#define MAX_ALLOWED_DIFF_LENGTH 256
Expand Down
17 changes: 14 additions & 3 deletions src/monk/agent/monkbulk.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int queryBulkArguments(MonkState* state, long bulkId) {
state->dbManager,
"queryBulkArguments",
"SELECT ut.upload_fk, ut.uploadtree_pk, lrb.user_fk, lrb.group_fk, "
"lrb.rf_text, lrb.ignore_irrelevant "
"lrb.rf_text, lrb.ignore_irrelevant, lrb.bulk_delimiters "
"FROM license_ref_bulk lrb INNER JOIN uploadtree ut "
"ON ut.uploadtree_pk = lrb.uploadtree_fk "
"WHERE lrb_pk = $1",
Expand All @@ -105,6 +105,15 @@ int queryBulkArguments(MonkState* state, long bulkId) {
bulkArguments->groupId = atoi(PQgetvalue(bulkArgumentsResult, 0, column++));
bulkArguments->refText = g_strdup(PQgetvalue(bulkArgumentsResult, 0, column++));
bulkArguments->ignoreIrre = strcmp(PQgetvalue(bulkArgumentsResult, 0, column++), "t") == 0;
if (PQgetisnull(bulkArgumentsResult, 0, column) == 1)
{
bulkArguments->delimiters = g_strdup(DELIMITERS);
column++;
}
else
{
bulkArguments->delimiters = normalize_escape_string(PQgetvalue(bulkArgumentsResult, 0, column++));
}
bulkArguments->bulkId = bulkId;
bulkArguments->actions = queryBulkActions(state, bulkId);
bulkArguments->jobId = fo_scheduler_jobId();
Expand Down Expand Up @@ -169,6 +178,7 @@ void bulkArguments_contents_free(BulkArguments* bulkArguments) {
free(bulkActions);

g_free(bulkArguments->refText);
g_free(bulkArguments->delimiters);

free(bulkArguments);
}
Expand All @@ -179,7 +189,7 @@ int bulk_identification(MonkState* state) {
License license = (License){
.refId = bulkArguments->licenseId,
};
license.tokens = tokenize(bulkArguments->refText, DELIMITERS);
license.tokens = tokenize(bulkArguments->refText, bulkArguments->delimiters);

GArray* licenseArray = g_array_new(FALSE, FALSE, sizeof (License));
g_array_append_val(licenseArray, license);
Expand Down Expand Up @@ -217,7 +227,8 @@ int bulk_identification(MonkState* state) {

long fileId = atol(PQgetvalue(filesResult, i, 0));

if (matchPFileWithLicenses(threadLocalState, fileId, licenses, &bulkCallbacks)) {
if (matchPFileWithLicenses(threadLocalState, fileId, licenses,
&bulkCallbacks, bulkArguments->delimiters)) {
fo_scheduler_heart(1);
} else {
fo_scheduler_heart(0);
Expand Down
1 change: 1 addition & 0 deletions src/monk/agent/monkbulk.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ typedef struct {
int groupId;
char* refText;
bool ignoreIrre;
char* delimiters;
BulkAction** actions;
} BulkArguments;

Expand Down
2 changes: 1 addition & 1 deletion src/monk/agent/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int processUploadId(MonkState* state, int uploadId, const Licenses* licenses) {
continue;
}

if (matchPFileWithLicenses(threadLocalState, pFileId, licenses, &schedulerCallbacks)) {
if (matchPFileWithLicenses(threadLocalState, pFileId, licenses, &schedulerCallbacks, DELIMITERS)) {
fo_scheduler_heart(1);
} else {
fo_scheduler_heart(0);
Expand Down
Loading