use of com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier in project sechub by mercedes-benz.
the class ExecutorConfigDialogUI method createMainPanel.
private void createMainPanel() {
ActionSupport actionSupport = ActionSupport.getInstance();
mainPanel = new JPanel(new GridBagLayout());
int row = 0;
/* name */
nameTextField = new JTextField(config.name);
mainPanel.add(new JLabel("Name"), createLabelConstraint(row));
mainPanel.add(nameTextField, createComponentConstraint(row++));
nameTextField.setBorder(BorderFactory.createLineBorder(Color.ORANGE, 2));
nameTextField.setToolTipText("mandatory field");
/* enabled */
enabledCheckBox = new JCheckBox("", config.enabled);
mainPanel.add(new JLabel("Enabled"), createLabelConstraint(row));
mainPanel.add(enabledCheckBox, createComponentConstraint(row++));
/* UUID readonly */
uuidTextField = new JTextField(config.uuid != null ? "" + config.uuid : null);
uuidTextField.setEditable(false);
mainPanel.add(new JLabel("UUID"), createLabelConstraint(row));
mainPanel.add(uuidTextField, createComponentConstraint(row++));
/* product */
ComboBoxModel<ProductIdentifier> comboBoxModel = new DefaultComboBoxModel<>(ProductIdentifier.values());
productIdentifierCombobox = new JComboBox<>(comboBoxModel);
productIdentifierCombobox.setSelectedItem(ProductIdentifier.valueOf(config.productIdentifier));
mainPanel.add(new JLabel("Product identifier"), createLabelConstraint(row));
mainPanel.add(productIdentifierCombobox, createComponentConstraint(row++));
SpinnerNumberModel versionSpinnerModel = new SpinnerNumberModel(1, 0, 9999, 1);
executorVersionTextField = new JSpinner(versionSpinnerModel);
executorVersionTextField.setValue(config.executorVersion);
mainPanel.add(new JLabel("Executor version"), createLabelConstraint(row));
mainPanel.add(executorVersionTextField, createComponentConstraint(row++));
/* base url */
baseURLTextField = new JTextField(config.setup.baseURL);
mainPanel.add(new JLabel("Product base url"), createLabelConstraint(row));
mainPanel.add(baseURLTextField, createComponentConstraint(row++));
actionSupport.provideUndoRedo(baseURLTextField);
/* credentials */
userTextField = new JTextField(config.setup.credentials.user);
mainPanel.add(new JLabel("Product user:"), createLabelConstraint(row));
mainPanel.add(userTextField, createComponentConstraint(row++));
pwdTextField = new JTextField(config.setup.credentials.password);
mainPanel.add(new JLabel("Product password/apitoken:"), createLabelConstraint(row));
mainPanel.add(pwdTextField, createComponentConstraint(row++));
/* template button */
JButton button = new JButton("Edit parameters");
mainPanel.add(button, createComponentConstraint(row++));
/* job parameters */
jobParametersTextArea = new JTextArea(resolveInitialJobParamsAsString());
actionSupport.installAllTextActionsAsPopupTo(jobParametersTextArea);
mainPanel.add(new JLabel("Parameters:"), createLabelConstraint(row));
jobParameterScrollPane = new JScrollPane(jobParametersTextArea);
GridBagConstraints jobParameterScrollPaneGridDataConstraints = createComponentConstraint(row++);
jobParameterScrollPaneGridDataConstraints.gridheight = 140;
jobParameterScrollPaneGridDataConstraints.weighty = 0.0;
jobParameterScrollPaneGridDataConstraints.fill = GridBagConstraints.BOTH;
jobParameterScrollPane.setPreferredSize(new Dimension(400, 300));
jobParameterScrollPane.setMinimumSize(new Dimension(400, 300));
mainPanel.add(jobParameterScrollPane, jobParameterScrollPaneGridDataConstraints);
button.addActionListener(e -> {
ProductIdentifier procutIdentifier = (ProductIdentifier) comboBoxModel.getSelectedItem();
int version = (int) versionSpinnerModel.getNumber();
ShowProductExecutorTemplatesDialogAction action = context.getCommandUI().resolveShowProductExecutorMappingDialogActionOrNull(procutIdentifier, version);
if (action == null) {
JOptionPane.showMessageDialog(context.getFrame(), "No special parameter editor dialog available for " + procutIdentifier + " v" + version);
return;
}
TemplatesDialogConfig config = new TemplatesDialogConfig();
config.inputContent = jobParametersTextArea.getText();
config.provideExportAllButton = true;
config.provideExportAllButtonText = "Apply";
/* open template dialog, auto import clipboard content and add apply button */
TemplatesDialogResult result = action.openDialog(config);
if (result.provideExportAllButtonPressed) {
jobParametersTextArea.setText(result.outputContent);
scrollToLeftTopOfJobParameters();
}
});
}
use of com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier in project sechub by mercedes-benz.
the class DeleteProductExecutorConfigService method deleteProductExecutorConfig.
/* @formatter:off */
@UseCaseAdminDeletesExecutorConfiguration(@Step(number = 2, name = "Service call", description = "Service deletes an existing product executor configuration by its UUID"))
public void deleteProductExecutorConfig(UUID uuid) {
auditLogService.log("Wants to removed product execution {}", uuid);
Optional<ProductExecutorConfig> opt = repository.findById(uuid);
if (!opt.isPresent()) {
LOG.info("Delete canceled, because executor config with uuid {} did not exist", uuid);
;
return;
}
ProductExecutorConfig found = opt.get();
String name = found.getName();
ProductIdentifier productIdentifier = found.getProductIdentifier();
Integer executorVersion = found.getExecutorVersion();
repository.deleteById(uuid);
LOG.info("Removed product execution config uuid:{}, name:{} which was for product:{} V{}", uuid, name, productIdentifier, executorVersion);
}
use of com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier in project sechub by mercedes-benz.
the class SerecoProductResultSpdxJsonResolver method resolveSpdxJson.
/**
* Fetches SPDX-Json from Sereco ProductResult
*
* @param serecoProductResult from Sereco
* @return SpdxJson as String or <code>null</code>
*/
@Override
public String resolveSpdxJson(ProductResult serecoProductResult) {
ProductIdentifier productIdentifier = serecoProductResult.getProductIdentifier();
if (!productIdentifier.equals(ProductIdentifier.SERECO)) {
throw new IllegalArgumentException("Must be of type Sereco, but was: " + productIdentifier);
}
String origin = serecoProductResult.getResult();
SerecoMetaData data = JSONConverter.get().fromJSON(SerecoMetaData.class, origin);
List<SerecoLicenseDocument> licenseDocuments = data.getLicenseDocuments();
for (SerecoLicenseDocument licenseDocument : licenseDocuments) {
SerecoLicenseSpdx spdx = licenseDocument.getSpdx();
if (spdx == null) {
continue;
}
String spdxJson = spdx.getJson();
if (spdxJson != null) {
return spdxJson;
}
}
LOG.info("No SPDX report found in the product results.");
return null;
}
use of com.mercedesbenz.sechub.domain.scan.product.ProductIdentifier in project sechub by mercedes-benz.
the class SerecoReportProductExecutor method createReport.
private ProductResult createReport(SecHubExecutionContext context, ProductExecutorContext executorContext) {
if (context == null) {
throw new IllegalArgumentException("context may not be null!");
}
String projectId = context.getConfiguration().getProjectId();
UUID secHubJobUUID = context.getSechubJobUUID();
UUIDTraceLogID traceLogId = UUIDTraceLogID.traceLogID(secHubJobUUID);
LOG.debug("{} start sereco execution", traceLogId);
/* load the results by job uuid */
ProductIdentifier[] supportedProducts = getSupportedProducts();
List<ProductResult> foundProductResults = productResultRepository.findAllProductResults(secHubJobUUID, supportedProducts);
if (foundProductResults.isEmpty()) {
LOG.warn("{} no product results for {} found, will return an empty sereco JSON as result! ", traceLogId, getSupportedProducts());
return new ProductResult(secHubJobUUID, projectId, executorContext.getExecutorConfig(), "{}");
}
return createReport(projectId, secHubJobUUID, traceLogId, executorContext, foundProductResults);
}
Aggregations