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

feat(atarashi): Add Atarashi to FOSSology #1408

Merged
merged 51 commits into from Feb 26, 2020
Merged
Show file tree
Hide file tree
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 May 27, 2019
4fb3dd1
fix(init.d): Implement missing function
GMishx May 29, 2019
db9f8c8
fix(api): Adhere to specification
GMishx Jun 24, 2019
64878b7
feat(copyright): Show text findings in copyright-hist
GMishx Mar 22, 2019
75fc125
fix(pfile): SHA256 is still optional
GMishx Jul 9, 2019
a8e0b93
feat(atarashi): add atarashi in fossology
hastagAB Jul 22, 2019
5a3e80b
fix(atarashi): Fix the wrapper for atarashi
GMishx Jul 16, 2019
2c61830
Merge pull request #1382 from siemens/fix/api/adherence-to-specification
ag4ums Jul 25, 2019
ff44b2a
Merge pull request #1359 from siemens/fix/build/clean-build-from-dirs
ag4ums Jul 29, 2019
32a72e6
Merge pull request #1311 from siemens/feat/copyright/test-findings-ui…
mcjaeger Aug 2, 2019
84cbbbb
feat(ojo): New license scanner for SPDX-License-Identifier
ag4ums Jun 6, 2017
3bccc40
test(ojo): Test cases
GMishx Jul 11, 2019
732aaf8
Merge branch 'master' into feat/atarashi
hastagAB Aug 3, 2019
6030561
update agent_test for atarashi
hastagAB Aug 3, 2019
0eaf91d
Merge pull request #842 from fossology/dev/new-license-scanner
ag4ums Aug 5, 2019
dcc429e
chore(debian): Fix lintian erros and warnings
GMishx May 9, 2019
beb69bd
Merge pull request #1348 from siemens/chore/debian/lintian-fixes
mcjaeger Aug 5, 2019
2839d5e
Merge pull request #1363 from siemens/fix/initd/register-using-updatercd
mcjaeger Aug 6, 2019
4790c63
feat(licenseRef): add new functionality to add new licenses and update
shaheemazmalmmd Mar 12, 2019
51c2daf
Merge pull request #1400 from siemens/fix/pfile/sha256
shaheemazmalmmd Aug 9, 2019
b6fdf11
hotfix(process): Fix the PHP agent installation
GMishx Aug 9, 2019
f094b29
Merge pull request #1426 from siemens/hotfix/removeExtraLinesFromPhp
ag4ums Aug 11, 2019
8cb4b00
fix(vagrant): reload systemd conf before first start
Aug 12, 2019
cec5732
Merge pull request #1308 from siemens/contrib/featExportLicensesFromSPDX
mcjaeger Aug 12, 2019
6eb4c07
chore(changelog): adding 3.6.0-rc1 info to changelog files
mcjaeger Aug 12, 2019
8bb6b09
Merge pull request #1428 from fossology/mcj/changelog-360-rc1
maxhbr Aug 12, 2019
bd13943
Merge pull request #1427 from andi8086/andreas/next
maxhbr Aug 13, 2019
281fafb
fix(copyright): show more than 100 copyrights on one page
Aug 13, 2019
49d901c
fix(ojo): Remove call to omitEndingLineFeed on<0.6
GMishx Aug 13, 2019
90b7f55
feat(unifiedreport): add candidate licenses to the list of obligations
shaheemazmalmmd Aug 19, 2019
4908a69
Merge pull request #1446 from siemens/contrib/fixIssue1440
GMishx Aug 20, 2019
83897a1
fix(obligation): add default value if the obligation type and classif…
shaheemazmalmmd Aug 19, 2019
69b03a3
fix(copyright): Check if empty decision sent
GMishx Aug 16, 2019
e401985
Merge pull request #1445 from siemens/contrib/fixIssue1439
GMishx Aug 20, 2019
afcab99
Merge pull request #1442 from siemens/fix/copyright/manualEntry-witho…
shaheemazmalmmd Aug 20, 2019
1ec57b2
feat(atarashi): add atarashi in fossology
hastagAB Jul 22, 2019
ce35b64
fix(atarashi): Fix the wrapper for atarashi
GMishx Jul 16, 2019
36b58d0
update agent_test for atarashi
hastagAB Aug 3, 2019
5be5026
feat(atarashi): added mod_deps to atarashi
hastagAB Aug 20, 2019
baebcf2
feat(atarashi): update
hastagAB Aug 20, 2019
78536eb
Merge branch 'master' into feat/atarashi
hastagAB Aug 20, 2019
6f52472
Merge pull request #1430 from siemens/fix/ojo/useStreamWriterBuilder
ag4ums Aug 20, 2019
f4c2de9
fix(dbMigrate): Fix PHP syntax error
GMishx Aug 19, 2019
1ebd166
Merge pull request #1444 from siemens/fix/dbmigrate/syntaxerror
shaheemazmalmmd Aug 23, 2019
6e0244e
chore(changelog): adding 3.6.0-rc2 info to changelog files
ag4ums Aug 24, 2019
ea841d8
Merge pull request #1454 from siemens/changelog-3.6-rc2
GMishx Aug 24, 2019
2b7881b
Merge pull request #1431 from andi8086/andreas/copyright-view
shaheemazmalmmd Aug 26, 2019
526a841
Merge branch 'master' into feat/atarashi
hastagAB Aug 29, 2019
c6e4c9c
fix(atarashi): Agent test fix
hastagAB Aug 29, 2019
6bb16a4
feat(atarashi):fixed Unit Test
hastagAB Aug 31, 2019
6b7a320
feat(atarashi): fixed functional test
hastagAB Aug 31, 2019
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
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -27,6 +27,8 @@ install/defconf/Db.conf
install/defconf/fossology.conf
install/fo-postinstall
src/adj2nest/agent/adj2nest
src/atarashi/agent/atarashiWrapper
src/atarashi/agent_tests/Functional/atarashiWrapper
src/buckets/agent/buckets
src/cli/cp2foss
src/cli/cp2foss.1
Expand Down
13 changes: 13 additions & 0 deletions install/scripts/install-atarashi.sh
@@ -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

Copy link
Contributor

@ag4ums ag4ums Aug 16, 2019

Choose a reason for hiding this comment

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

  • This installation script can be move to agent's mod_deps file(not in its current form), as different distro support different version of installed package.
  • Also please install pip using distro default install method (eg : apt-get install python3-pip for ubuntu)
    and then upgrade the pip to its current version
  • You can use this script as a ref https://github.com/fossology/fossology/blob/master/src/ojo/mod_deps

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
1 change: 1 addition & 0 deletions src/Makefile
Expand Up @@ -11,6 +11,7 @@ include $(VARS)
DIRS = \
adj2nest \
buckets \
atarashi \
cli \
copyright \
debug \
Expand Down
50 changes: 50 additions & 0 deletions src/atarashi/Makefile
@@ -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
11 changes: 11 additions & 0 deletions src/atarashi/README.md
@@ -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
66 changes: 66 additions & 0 deletions src/atarashi/agent/Makefile
@@ -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
54 changes: 54 additions & 0 deletions src/atarashi/agent/atarashi.cc
@@ -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;
}
27 changes: 27 additions & 0 deletions src/atarashi/agent/atarashi.hpp
@@ -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 added src/atarashi/agent/atarashiWrapper
Binary file not shown.
73 changes: 73 additions & 0 deletions src/atarashi/agent/atarashiwrapper.cc
@@ -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;
}
33 changes: 33 additions & 0 deletions src/atarashi/agent/atarashiwrapper.hpp
@@ -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