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
feat(atarashi): Add Atarashi to FOSSology #1408
Merged
ag4ums
merged 51 commits into
fossology:feat/newagent/atarashi
from
hastagAB:feat/atarashi
Feb 26, 2020
Merged
Changes from 10 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
5ef99c9
fix(build): Fix clean build from all dirs
GMishx 4fb3dd1
fix(init.d): Implement missing function
GMishx db9f8c8
fix(api): Adhere to specification
GMishx 64878b7
feat(copyright): Show text findings in copyright-hist
GMishx 75fc125
fix(pfile): SHA256 is still optional
GMishx a8e0b93
feat(atarashi): add atarashi in fossology
hastagAB 5a3e80b
fix(atarashi): Fix the wrapper for atarashi
GMishx 2c61830
Merge pull request #1382 from siemens/fix/api/adherence-to-specification
ag4ums ff44b2a
Merge pull request #1359 from siemens/fix/build/clean-build-from-dirs
ag4ums 32a72e6
Merge pull request #1311 from siemens/feat/copyright/test-findings-ui…
mcjaeger 84cbbbb
feat(ojo): New license scanner for SPDX-License-Identifier
ag4ums 3bccc40
test(ojo): Test cases
GMishx 732aaf8
Merge branch 'master' into feat/atarashi
hastagAB 6030561
update agent_test for atarashi
hastagAB 0eaf91d
Merge pull request #842 from fossology/dev/new-license-scanner
ag4ums dcc429e
chore(debian): Fix lintian erros and warnings
GMishx beb69bd
Merge pull request #1348 from siemens/chore/debian/lintian-fixes
mcjaeger 2839d5e
Merge pull request #1363 from siemens/fix/initd/register-using-updatercd
mcjaeger 4790c63
feat(licenseRef): add new functionality to add new licenses and update
shaheemazmalmmd 51c2daf
Merge pull request #1400 from siemens/fix/pfile/sha256
shaheemazmalmmd b6fdf11
hotfix(process): Fix the PHP agent installation
GMishx f094b29
Merge pull request #1426 from siemens/hotfix/removeExtraLinesFromPhp
ag4ums 8cb4b00
fix(vagrant): reload systemd conf before first start
cec5732
Merge pull request #1308 from siemens/contrib/featExportLicensesFromSPDX
mcjaeger 6eb4c07
chore(changelog): adding 3.6.0-rc1 info to changelog files
mcjaeger 8bb6b09
Merge pull request #1428 from fossology/mcj/changelog-360-rc1
maxhbr bd13943
Merge pull request #1427 from andi8086/andreas/next
maxhbr 281fafb
fix(copyright): show more than 100 copyrights on one page
49d901c
fix(ojo): Remove call to omitEndingLineFeed on<0.6
GMishx 90b7f55
feat(unifiedreport): add candidate licenses to the list of obligations
shaheemazmalmmd 4908a69
Merge pull request #1446 from siemens/contrib/fixIssue1440
GMishx 83897a1
fix(obligation): add default value if the obligation type and classif…
shaheemazmalmmd 69b03a3
fix(copyright): Check if empty decision sent
GMishx e401985
Merge pull request #1445 from siemens/contrib/fixIssue1439
GMishx afcab99
Merge pull request #1442 from siemens/fix/copyright/manualEntry-witho…
shaheemazmalmmd 1ec57b2
feat(atarashi): add atarashi in fossology
hastagAB ce35b64
fix(atarashi): Fix the wrapper for atarashi
GMishx 36b58d0
update agent_test for atarashi
hastagAB 5be5026
feat(atarashi): added mod_deps to atarashi
hastagAB baebcf2
feat(atarashi): update
hastagAB 78536eb
Merge branch 'master' into feat/atarashi
hastagAB 6f52472
Merge pull request #1430 from siemens/fix/ojo/useStreamWriterBuilder
ag4ums f4c2de9
fix(dbMigrate): Fix PHP syntax error
GMishx 1ebd166
Merge pull request #1444 from siemens/fix/dbmigrate/syntaxerror
shaheemazmalmmd 6e0244e
chore(changelog): adding 3.6.0-rc2 info to changelog files
ag4ums ea841d8
Merge pull request #1454 from siemens/changelog-3.6-rc2
GMishx 2b7881b
Merge pull request #1431 from andi8086/andreas/copyright-view
shaheemazmalmmd 526a841
Merge branch 'master' into feat/atarashi
hastagAB c6e4c9c
fix(atarashi): Agent test fix
hastagAB 6bb16a4
feat(atarashi):fixed Unit Test
hastagAB 6b7a320
feat(atarashi): fixed functional test
hastagAB File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
sudo apt-get install software-properties-common | ||
sudo add-apt-repository ppa:deadsnakes/ppa | ||
sudo apt-get update | ||
sudo apt-get install python>=3.6 | ||
|
||
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py | ||
python3 get-pip.py | ||
|
||
pip install -i https://test.pypi.org/simple/ atarashi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ include $(VARS) | |
DIRS = \ | ||
adj2nest \ | ||
buckets \ | ||
atarashi \ | ||
cli \ | ||
copyright \ | ||
debug \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright Siemens AG 2019-2020 | ||
# | ||
# Copying and distribution of this file, with or without modification, | ||
# are permitted in any medium without royalty provided the copyright | ||
# notice and this notice are preserved. This file is offered as-is, | ||
# without any warranty. | ||
|
||
TOP = ../.. | ||
VARS = $(TOP)/Makefile.conf | ||
include $(VARS) | ||
|
||
MOD_NAME = atarashiWrapper | ||
|
||
DIRS = agent ui | ||
TESTDIR = agent_tests | ||
|
||
DIR_LOOP = @set -e; for dir in $(DIRS); do $(MAKE) -s -C $$dir $(1); done | ||
|
||
all: VERSIONFILE | ||
$(call DIR_LOOP, ) | ||
|
||
test: all | ||
$(TOP)/install/scripts/install-atarashi.sh | ||
$(MAKE) -C $(TESTDIR) test | ||
|
||
coverage: all | ||
$(MAKE) -C $(TESTDIR) coverage | ||
|
||
VERSIONFILE: | ||
$(call WriteVERSIONFile,$(MOD_NAME)) | ||
|
||
install: all | ||
$(call DIR_LOOP,install) | ||
$(INSTALL_DATA) VERSION $(DESTDIR)$(MODDIR)/$(MOD_NAME)/VERSION | ||
$(INSTALL_DATA) $(MOD_NAME).conf $(DESTDIR)$(MODDIR)/$(MOD_NAME)/$(MOD_NAME).conf | ||
mkdir -p $(DESTDIR)$(SYSCONFDIR)/mods-enabled | ||
if test ! -e $(DESTDIR)$(SYSCONFDIR)/mods-enabled/$(MOD_NAME); then \ | ||
ln -s $(MODDIR)/$(MOD_NAME) $(DESTDIR)$(SYSCONFDIR)/mods-enabled; \ | ||
fi | ||
|
||
uninstall: | ||
$(call DIR_LOOP,uninstall) | ||
rm -rf $(DESTDIR)$(MODDIR)/$(MOD_NAME) | ||
rm -f $(DESTDIR)$(SYSCONFDIR)/mods-enabled/$(MOD_NAME) | ||
|
||
clean: | ||
$(call DIR_LOOP,clean) | ||
rm -f VERSION | ||
|
||
.PHONY: all test coverage VERSIONFILE install uninstall clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Introduction | ||
-------------- | ||
|
||
Atarashi scans for license statements in open source software, focusing on text statistics. Designed to work stand-alone and with FOSSology. http://fossology.github.io/atarashi | ||
|
||
This FOSSology plugin is a wrapper for Atarashi. | ||
|
||
Download | ||
-------------- | ||
|
||
https://github.com/fossology/atarashi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright Siemens AG 2019-2020 | ||
# | ||
# Copying and distribution of this file, with or without modification, | ||
# are permitted in any medium without royalty provided the copyright | ||
# notice and this notice are preserved. This file is offered as-is, | ||
# without any warranty. | ||
|
||
TOP = ../../.. | ||
VARS = $(TOP)/Makefile.conf | ||
include $(VARS) | ||
|
||
MOD_NAME = atarashiWrapper | ||
DEF = -DDATADIR='"$(MODDIR)"' | ||
CXXFLAGS_LOCAL = $(FO_CXXFLAGS) -I. -Wall -fopenmp $(shell pkg-config --cflags jsoncpp) | ||
CXXFLAGS_LINK = $(FO_CXXLDFLAGS) -fopenmp $(shell pkg-config --libs jsoncpp) | ||
|
||
EXE = atarashiWrapper | ||
|
||
OBJECTS = databasehandler.o licensematch.o atarashi.o atarashiwrapper.o state.o utils.o | ||
COVERAGE = $(OBJECTS:%.o=%_cov.o) | ||
|
||
all: $(CXXFOLIB) $(EXE) | ||
|
||
$(EXE): $(CXXFOLIB) $(VARS) $(OBJECTS) | ||
$(CXX) $(OBJECTS) $(DEF) $(CXXFLAGS_LINK) -o $@ | ||
|
||
$(EXE)_cov: $(CXXFOLIB) $(VARS) $(COVERAGE) | ||
$(CXX) $(COVERAGE) $(FLAG_COV) $(DEF) $(CXXFLAGS_LINK) -o $@ | ||
|
||
####################### | ||
# library build rules # | ||
####################### | ||
|
||
$(CXXFOLIB): | ||
$(MAKE) -C $(CXXFOLIBDIR) | ||
|
||
libatarashi.a: $(OBJECTS) | ||
ar cvr $@ $(OBJECTS) | ||
|
||
libatarashi_cov.a: $(COVERAGE) | ||
ar cvr $@ $(COVERAGE) | ||
|
||
###################### | ||
# object build rules # | ||
###################### | ||
|
||
$(OBJECTS): %.o: %.cc %.hpp | ||
$(CXX) -c $(CXXFLAGS_LOCAL) $(DEF) $< | ||
|
||
$(COVERAGE): %_cov.o: %.cc %.hpp | ||
$(CXX) -c $< $(CXXFLAGS_LOCAL) $(FLAG_COV) $(DEF) $(DEFS) -o $@ | ||
|
||
####################### | ||
# install build rules # | ||
####################### | ||
|
||
install: $(EXE) | ||
$(INSTALL_PROGRAM) $(EXE) $(DESTDIR)$(MODDIR)/$(MOD_NAME)/agent/$(EXE) | ||
|
||
uninstall: | ||
rm -rf $(DESTDIR)$(MODDIR)/$(MOD_NAME)/$(EXE)/agent | ||
|
||
clean: | ||
rm -f $(EXE) *.o *.a *.gcno *.gcda core | ||
|
||
.PHONY: all install uninstall clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (C) 2019-2020, Siemens AG | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* version 2 as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#include "atarashi.hpp" | ||
|
||
using namespace fo; | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
/* before parsing argv and argc make sure */ | ||
/* to initialize the scheduler connection */ | ||
|
||
DbManager dbManager(&argc, argv); | ||
AtarashiDatabaseHandler databaseHandler(dbManager); | ||
|
||
State state = getState(dbManager); | ||
|
||
while (fo_scheduler_next() != NULL) | ||
{ | ||
int uploadId = atoi(fo_scheduler_current()); | ||
|
||
if (uploadId == 0) continue; | ||
|
||
int arsId = writeARS(state, 0, uploadId, 0, dbManager); | ||
|
||
if (arsId <= 0) | ||
bail(5); | ||
|
||
if (!processUploadId(state, uploadId, databaseHandler)) | ||
bail(2); | ||
|
||
fo_scheduler_heart(0); | ||
writeARS(state, arsId, uploadId, 1, dbManager); | ||
} | ||
fo_scheduler_heart(0); | ||
|
||
/* do not use bail, as it would prevent the destructors from running */ | ||
fo_scheduler_disconnect(0); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2019-2020, Siemens AG | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* version 2 as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifndef ATARASHI_AGENT_ATARASHI_HPP | ||
#define ATARASHI_AGENT_ATARASHI_HPP | ||
|
||
#include "utils.hpp" | ||
|
||
extern "C" { | ||
#include "libfossagent.h" | ||
} | ||
|
||
#endif // ATARASHI_AGENT_ATARASHI_HPP |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (C) 2019-2020, Siemens AG | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* version 2 as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#include <iostream> | ||
#include <boost/tokenizer.hpp> | ||
#include "atarashiwrapper.hpp" | ||
#include "utils.hpp" | ||
|
||
string scanFileWithAtarashi(const State& state, const fo::File& file) | ||
{ | ||
FILE* in; | ||
char buffer[512]; | ||
string command = "atarashi -a DLD " + file.getFileName(); //Testing only for DLD Now | ||
string result; | ||
|
||
if (!(in = popen(command.c_str(), "r"))) | ||
{ | ||
cout << "could not execute atarashi command: " << command << endl; | ||
bail(1); | ||
} | ||
|
||
while (fgets(buffer, sizeof(buffer), in) != NULL) | ||
{ | ||
result += buffer; | ||
} | ||
|
||
if (pclose(in) != 0) | ||
{ | ||
cout << "could not execute atarashi command: " << command << endl; | ||
bail(1); | ||
} | ||
|
||
int jsonStart = result.find("{"); | ||
return result.substr(jsonStart, string::npos); | ||
} | ||
|
||
vector<LicenseMatch> extractLicensesFromAtarashiResult(string atarashiResult) | ||
{ | ||
Json::Reader reader; | ||
Json::Value atarashiResultobj; | ||
bool parseSuccess = reader.parse(atarashiResult, atarashiResultobj); | ||
|
||
if (!parseSuccess) | ||
{ | ||
cout << "Failed to parse" << reader.getFormattedErrorMessages(); | ||
bail(-30); | ||
} | ||
|
||
vector<LicenseMatch> matches; | ||
Json::Value resultArray = atarashiResultobj["results"]; | ||
for (unsigned int index = 0; index < resultArray.size(); ++index) | ||
{ | ||
Json::Value resultObject = resultArray[index]; | ||
LicenseMatch m(resultObject["shortname"].asString(), | ||
(unsigned)(resultObject["sim_score"].asDouble() * 100.0)); | ||
matches.push_back(m); | ||
} | ||
return matches; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (C) 2019-2020, Siemens AG | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* version 2 as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifndef ATARASHI_AGENT_ATARASHI_WRAPPER_HPP | ||
#define ATARASHI_AGENT_ATARASHI_WRAPPER_HPP | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <jsoncpp/json/json.h> | ||
|
||
#include "files.hpp" | ||
#include "licensematch.hpp" | ||
#include "state.hpp" | ||
|
||
using namespace std; | ||
|
||
string scanFileWithAtarashi(const State& state, const fo::File& file); | ||
vector<LicenseMatch> extractLicensesFromAtarashiResult(string atarashiResult); | ||
#endif // ATARASHI_AGENT_ATARASHI_WRAPPER_HPP |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and then upgrade the pip to its current version