Skip to content

Commit

Permalink
Merge branch 'master' into issues/301
Browse files Browse the repository at this point in the history
  • Loading branch information
chambridge committed Jan 16, 2018
2 parents c62a425 + 4265c57 commit 1663c6e
Show file tree
Hide file tree
Showing 11 changed files with 417 additions and 14 deletions.
28 changes: 23 additions & 5 deletions client/src/redux/actions/credentialsActions.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
import * as types from '../constants/credentialsConstants';
import credentialsApi from '../../services/credentialsApi';

const loadCredentialsSuccess = data => ({
const credentialsError = (bool, message) => ({
type: types.LOAD_CREDENTIALS_ERROR,
error: bool,
message: message
});

const credentialsLoading = bool => ({
type: types.LOAD_CREDENTIALS_LOADING,
loading: bool
});

const credentialsSuccess = data => ({
type: types.LOAD_CREDENTIALS_SUCCESS,
data
});

const getCredentials = () => {
return function(dispatch) {
dispatch(credentialsLoading(true));
return credentialsApi
.getCredentials()
.then(success => {
dispatch(loadCredentialsSuccess(success));
dispatch(credentialsSuccess(success));
})
.catch(error => {
throw error;
});
dispatch(credentialsError(true, error.message));
})
.finally(() => dispatch(credentialsLoading(false)));
};
};

export { loadCredentialsSuccess, getCredentials };
export {
credentialsError,
credentialsLoading,
credentialsSuccess,
getCredentials
};
23 changes: 18 additions & 5 deletions client/src/redux/actions/scansActions.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
import * as types from '../constants/scansConstants';
import scansApi from '../../services/scansApi';

const loadScansSuccess = data => ({
const scansError = (bool, message) => ({
type: types.LOAD_SCANS_ERROR,
error: bool,
message: message
});

const scansLoading = bool => ({
type: types.LOAD_SCANS_LOADING,
loading: bool
});

const scansSuccess = data => ({
type: types.LOAD_SCANS_SUCCESS,
data
});

const getScans = () => {
return function(dispatch) {
dispatch(scansLoading(true));
return scansApi
.getScans()
.then(success => {
dispatch(loadScansSuccess(success));
dispatch(scansSuccess(success));
})
.catch(error => {
throw error;
});
dispatch(scansError(true, error.message));
})
.finally(() => dispatch(scansLoading(false)));
};
};

export { loadScansSuccess, getScans };
export { scansError, scansLoading, scansSuccess, getScans };
8 changes: 7 additions & 1 deletion client/src/redux/constants/credentialsConstants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
const LOAD_CREDENTIALS_ERROR = 'LOAD_CREDENTIALS_ERROR';
const LOAD_CREDENTIALS_LOADING = 'LOAD_CREDENTIALS_LOADING';
const LOAD_CREDENTIALS_SUCCESS = 'LOAD_CREDENTIALS_SUCCESS';

export { LOAD_CREDENTIALS_SUCCESS };
export {
LOAD_CREDENTIALS_ERROR,
LOAD_CREDENTIALS_LOADING,
LOAD_CREDENTIALS_SUCCESS
};
4 changes: 3 additions & 1 deletion client/src/redux/constants/scansConstants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const LOAD_SCANS_ERROR = 'LOAD_SCANS_ERROR';
const LOAD_SCANS_LOADING = 'LOAD_SCANS_LOADING';
const LOAD_SCANS_SUCCESS = 'LOAD_SCANS_SUCCESS';

export { LOAD_SCANS_SUCCESS };
export { LOAD_SCANS_ERROR, LOAD_SCANS_LOADING, LOAD_SCANS_SUCCESS };
15 changes: 14 additions & 1 deletion client/src/redux/reducers/credentialsReducer.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import * as types from '../constants/credentialsConstants';

const initialState = {
error: false,
errorMessage: '',
loading: true,
data: []
};

export default function credentialsReducer(state = initialState, action) {
switch (action.type) {
case types.LOAD_CREDENTIALS_ERROR:
return Object.assign({}, state, {
error: action.error,
errorMessage: action.message
});

case types.LOAD_CREDENTIALS_LOADING:
return Object.assign({}, state, { loading: action.loading });

case types.LOAD_CREDENTIALS_SUCCESS:
return Object.assign({}, state, action.data);
return Object.assign({}, state, { data: action.data });

default:
return state;
}
Expand Down
15 changes: 14 additions & 1 deletion client/src/redux/reducers/scansReducer.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import * as types from '../constants/scansConstants';

const initialState = {
error: false,
errorMessage: '',
loading: true,
data: []
};

export default function scansReducer(state = initialState, action) {
switch (action.type) {
case types.LOAD_SCANS_ERROR:
return Object.assign({}, state, {
error: action.error,
errorMessage: action.message
});

case types.LOAD_SCANS_LOADING:
return Object.assign({}, state, { loading: action.loading });

case types.LOAD_SCANS_SUCCESS:
return Object.assign({}, state, action.data);
return Object.assign({}, state, { data: action.data });

default:
return state;
}
Expand Down
1 change: 1 addition & 0 deletions quipucords/scanner/network/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def inspect_scan(self):
'etc_release',
'file_contents',
'jboss_eap',
'jboss_fuse_on_karaf',
'ifconfig',
'redhat_release',
'subman',
Expand Down
1 change: 1 addition & 0 deletions quipucords/scanner/network/processing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@

# flake8: noqa
from . import eap
from . import karaf
114 changes: 114 additions & 0 deletions quipucords/scanner/network/processing/karaf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Copyright (c) 2018 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public License,
# version 3 (GPLv3). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3
# along with this software; if not, see
# https://www.gnu.org/licenses/gpl-3.0.txt.

"""Initial processing of the shell output from the jboss_fuse_on_karaf role."""

import logging
from scanner.network.processing import process

logger = logging.getLogger(__name__) # pylint: disable=invalid-name

# pylint: disable=too-few-public-methods

# #### Processors ####

FIND_WARNING = 'find: WARNING: Hard link count is wrong for /proc: this may' \
' be a bug in your filesystem driver.'


class ProcessKarafRunningProcesses(process.Processor):
"""Process a list of Jboss Fuse on Karaf processes."""

KEY = 'karaf_running_processes'

@staticmethod
def process(output):
"""Preserve the output except for a known issue."""
if FIND_WARNING in output['stdout']:
logging.error('Find command failed')
return process.NO_DATA

return output['stdout'].strip()


class ProcessFindKaraf(process.Processor):
"""Process the results of a find command."""

KEY = 'karaf_find_karaf_jar'

@staticmethod
def process(output):
"""Return the command's output."""
print('\n\n\nProcessFindKaraf )line 50): \n')
print(str(output['stdout_lines']))
return output['stdout_lines']


class ProcessLocateKaraf(process.Processor):
"""Process the output of 'locate jboss.fuse-on-karaf.karaf-home'."""

KEY = 'karaf_locate_karaf_jar'

DEPS = ['have_locate']

@staticmethod
def process(output):
"""Pass the output back through."""
return output['stdout_lines']


class InitLineFinder(process.Processor):
"""Process the output of an init system.
For both chkconfig and systemctl list-unit-files, we look for
lines where the first (whitespace-delineated) element contains
'jboss' or 'fuse'.
"""

# This same code is in eap but I wasn't sure how to make the keyword an
# argument since it is in a class (without doing an __init__)
KEY = None

@staticmethod
def process(output):
"""Find lines where the first element contains 'jboss' or 'fuse'."""
matches = []

for line in output['stdout_lines']:
if not line:
continue

start = line.split()[0]
if 'jboss' in start or 'fuse' in start:
matches.append(line.strip())

return matches


class ProcessJbossFuseChkconfig(InitLineFinder):
"""Process the output of 'chkconfig'."""

KEY = 'jboss_fuse_chkconfig'


class ProcessJbossFuseSystemctl(InitLineFinder):
"""Process the output of 'systemctl list-unit-files'."""

KEY = 'jboss_fuse_systemctl_unit_files'


class ProcessKarafHomeBinFuse(process.Processor):
"""Process karaf home indicators to detect Fuse-on-Karaf."""

KEY = 'karaf_home_bin_fuse'

@staticmethod
def process(output):
"""Pass the output back through."""
return output['stdout_lines']
Loading

0 comments on commit 1663c6e

Please sign in to comment.