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

Adding Yocto Scanner support. #1824

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<changelist>-SNAPSHOT</changelist>
<module.name>${project.groupId}.warnings.ng</module.name>

<analysis-model-api.version>12.4.0</analysis-model-api.version>
<analysis-model-api.version>12.5.0</analysis-model-api.version>
<analysis-model-tests.version>${analysis-model-api.version}</analysis-model-tests.version>
<pull-request-monitoring.version>335.v525cd64ec76b_</pull-request-monitoring.version>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.jenkins.plugins.analysis.warnings;

import org.kohsuke.stapler.DataBoundConstructor;
import org.jenkinsci.Symbol;
import hudson.Extension;

import io.jenkins.plugins.analysis.core.model.AnalysisModelParser;
import io.jenkins.plugins.analysis.core.model.StaticAnalysisLabelProvider;
import io.jenkins.plugins.analysis.core.model.SymbolIconLabelProvider;

/**
* Provides a parser and customized messages for Yocto Scanner CLI (scannercli) reports.
*
* @author Michael Trimarchi
*/
public class YoctoScanner extends AnalysisModelParser {
private static final long serialVersionUID = 1L;
private static final String ID = "yoctocli";

/**
* Creates a new instance of {@link YoctoScanner}.
*/
@DataBoundConstructor
public YoctoScanner() {
super();
// empty constructor required for stapler
}

/** Descriptor for this static analysis tool. */
@Symbol("yoctoScanner")
@Extension
public static class Descriptor extends AnalysisModelParserDescriptor {
/** Creates the descriptor instance. */
public Descriptor() {
super(ID);
}

@Override
public boolean canScanConsoleLog() {
return false;
}

@Override
public boolean isPostProcessingEnabled() {
return false;
}

@Override
public StaticAnalysisLabelProvider getLabelProvider() {
return new SymbolIconLabelProvider(getId(), getDisplayName(), getDescriptionProvider(), "symbol-solid/shield-halved plugin-font-awesome-api");
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

What about adding another icon? The default warning icon might be inappropriate for security warnings?

We can select from: https://fontawesome.com/icons/categories/security or https://ionic.io/ionicons

Example code to change the icon: https://github.com/jenkinsci/warnings-ng-plugin/blob/main/plugin/src/main/java/io/jenkins/plugins/analysis/warnings/ErrorProne.java

Copy link
Contributor Author

Choose a reason for hiding this comment

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

diff --git a/plugin/pom.xml b/plugin/pom.xml
index 87a6b108c..b61c37f9f 100644
--- a/plugin/pom.xml
+++ b/plugin/pom.xml
@@ -25,7 +25,7 @@
     <changelist>-SNAPSHOT</changelist>
     <module.name>${project.groupId}.warnings.ng</module.name>
 
-    <analysis-model-api.version>12.4.0</analysis-model-api.version>
+    <analysis-model-api.version>12.5.0</analysis-model-api.version>
     <analysis-model-tests.version>${analysis-model-api.version}</analysis-model-tests.version>
     <pull-request-monitoring.version>335.v525cd64ec76b_</pull-request-monitoring.version>

This for the pom

diff --git a/plugin/src/main/java/io/jenkins/plugins/analysis/warnings/YoctoScanner.java b/plugin/src/main/java/io/jenkins/plugins/analysis/warnings/YoctoScanner.java
index c41df8dc4..5e121760f 100644
--- a/plugin/src/main/java/io/jenkins/plugins/analysis/warnings/YoctoScanner.java
+++ b/plugin/src/main/java/io/jenkins/plugins/analysis/warnings/YoctoScanner.java
@@ -5,6 +5,7 @@ import org.jenkinsci.Symbol;
import hudson.Extension;

import io.jenkins.plugins.analysis.core.model.AnalysisModelParser;
+import io.jenkins.plugins.analysis.core.model.SymbolIconLabelProvider;

/**
 * Provides a parser and customized messages for Yocto Scanner CLI (scannercli) reports.
@@ -42,5 +43,10 @@ public class YoctoScanner extends AnalysisModelParser {
        public boolean isPostProcessingEnabled() {
            return false;
        }
+
+        @Override
+        public StaticAnalysisLabelProvider getLabelProvider() {
+            return new SymbolIconLabelProvider(getId(), getDisplayName(), getDescriptionProvider(), "symbol-solid/bug plugin-font-awesome-api");
+        }

how icon are loaded?

Copy link
Member

Choose a reason for hiding this comment

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

Icons are part of a different plug-in and are referenced in the UI.

The bug is used for bug finders so you better should use a different one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@uhafner uhafner Sep 14, 2024

Choose a reason for hiding this comment

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

This one is not available. You need to choose a free one, there is a checkbox

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@uhafner Add the icon and tested, include the pom.xml change
Screenshot from 2024-09-15 21-32-28

Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ void shouldFindAllYamlLintIssues() {
shouldFindIssuesOfTool(4, new YamlLint(), "yamllint.txt");
}

/** Runs the YamlLint parser on an output file that contains 4 issues. */
@Test
void shouldFindAllYoctoIssues() {
shouldFindIssuesOfTool(25, new YoctoScanner(), "yocto_scanner_result.json");
}

/** Runs the Iar parser on an output file that contains 6 issues. */
@Test
void shouldFindAllIarIssues() {
Expand Down
Loading
Loading