Skip to content

Commit e5e9623

Browse files
authored
Merge branch 'main' into bug-modules
2 parents 8cedf8c + 6ee65b8 commit e5e9623

File tree

8 files changed

+94
-36
lines changed

8 files changed

+94
-36
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ jobs:
8888
8989
# Store already-built plugin as an artifact for downloading
9090
- name: Upload artifact
91-
uses: actions/upload-artifact@v5
91+
uses: actions/upload-artifact@v6
9292
with:
9393
name: ${{ steps.artifact.outputs.filename }}
9494
path: ./build/distributions/content/*/*
@@ -124,7 +124,7 @@ jobs:
124124
# Collect Tests Result of failed tests
125125
- name: Collect Tests Result
126126
if: ${{ failure() }}
127-
uses: actions/upload-artifact@v5
127+
uses: actions/upload-artifact@v6
128128
with:
129129
name: tests-result
130130
path: ${{ github.workspace }}/build/reports/tests
@@ -146,13 +146,6 @@ jobs:
146146
pull-requests: write
147147
steps:
148148

149-
# Free GitHub Actions Environment Disk Space
150-
- name: Maximize Build Space
151-
uses: jlumbroso/free-disk-space@main
152-
with:
153-
tool-cache: false
154-
large-packages: false
155-
156149
# Check out current repository
157150
- name: Fetch Sources
158151
uses: actions/checkout@v6
@@ -166,7 +159,7 @@ jobs:
166159

167160
# Run Qodana inspections
168161
- name: Qodana - Code Inspection
169-
uses: JetBrains/qodana-action@v2025.2.1
162+
uses: JetBrains/qodana-action@v2025.3.1
170163
with:
171164
cache-default-branch-only: true
172165

@@ -177,13 +170,6 @@ jobs:
177170
runs-on: ubuntu-latest
178171
steps:
179172

180-
# Free GitHub Actions Environment Disk Space
181-
- name: Maximize Build Space
182-
uses: jlumbroso/free-disk-space@main
183-
with:
184-
tool-cache: false
185-
large-packages: false
186-
187173
# Check out current repository
188174
- name: Fetch Sources
189175
uses: actions/checkout@v6
@@ -197,13 +183,13 @@ jobs:
197183

198184
# Setup Gradle
199185
- name: Setup Gradle
200-
uses: gradle/gradle-build-action@v3.4.2
186+
uses: gradle/gradle-build-action@v3.5.0
201187
with:
202188
gradle-home-cache-cleanup: true
203189

204190
# Cache Plugin Verifier IDEs
205191
- name: Setup Plugin Verifier IDEs Cache
206-
uses: actions/cache@v4
192+
uses: actions/cache@v5
207193
with:
208194
path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides
209195
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
@@ -215,7 +201,7 @@ jobs:
215201
# Collect Plugin Verifier Result
216202
- name: Collect Plugin Verifier Result
217203
if: ${{ always() }}
218-
uses: actions/upload-artifact@v5
204+
uses: actions/upload-artifact@v6
219205
with:
220206
name: pluginVerifier-result
221207
path: ${{ github.workspace }}/build/reports/pluginVerifier

.github/workflows/codeql.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
matrix:
4545
include:
4646
- language: java-kotlin
47-
build-mode: autobuild
47+
build-mode: manual
4848
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
4949
# Use `c-cpp` to analyze code written in C, C++ or both
5050
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
@@ -79,12 +79,7 @@ jobs:
7979
- if: matrix.build-mode == 'manual'
8080
shell: bash
8181
run: |
82-
echo 'If you are using a "manual" build mode for one or more of the' \
83-
'languages you are analyzing, replace this with the commands to build' \
84-
'your code, for example:'
85-
echo ' make bootstrap'
86-
echo ' make release'
87-
exit 1
82+
./gradlew compileKotlin
8883
8984
- name: Perform CodeQL Analysis
9085
uses: github/codeql-action/analyze@v4

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies {
2626
// implementation(libs.annotations)
2727
implementation("com.contrastsecurity:java-sarif:2.0")
2828
constraints {
29-
implementation("com.fasterxml.jackson.core:jackson-databind:2.20.0")
29+
implementation("com.fasterxml.jackson.core:jackson-databind:2.20.1")
3030
}
3131
testImplementation("org.assertj:assertj-core:3.27.6")
3232
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
annotations = "26.0.2-1"
44

55
# plugins
6-
changelog = "2.4.0"
6+
changelog = "2.5.0"
77
kotlin = "2.2.21"
88
gradleIntelliJPlugin = "1.17.4"
99
qodana = "0.1.13"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.github.adrienpessu.sarifviewer
2+
3+
import com.github.adrienpessu.sarifviewer.toolWindow.SarifViewerWindowFactory
4+
import com.intellij.json.JsonFileType
5+
import com.intellij.openapi.fileTypes.INativeFileType
6+
import com.intellij.openapi.project.Project
7+
import com.intellij.openapi.vfs.VirtualFile
8+
import com.intellij.openapi.wm.ToolWindowManager
9+
import com.intellij.ui.IconManager
10+
import com.intellij.ui.components.JBPanel
11+
import javax.swing.Icon
12+
13+
object SarifFileType : JsonFileType(), INativeFileType {
14+
override fun getName() = "SARIF"
15+
override fun getDescription() = "SARIF file"
16+
override fun getDefaultExtension() = "sarif"
17+
override fun getIcon(): Icon = load("com.github.adrienpessu.sarifviewer/sarif.svg", -2129886975, 0);
18+
19+
20+
override fun openFileInAssociatedApplication(project: Project?, file: VirtualFile): Boolean {
21+
if (project == null) return false
22+
23+
val toolWindow = ToolWindowManager
24+
.getInstance(project)
25+
.getToolWindow("Sarif viewer")
26+
27+
28+
toolWindow?.contentManager?.selectedContent?.component
29+
?.let { component ->
30+
if (component is SarifViewerWindowFactory.MyToolWindow) {
31+
component.openFile(project,file.toNioPath().toFile())
32+
}
33+
}
34+
35+
toolWindow?.show() // opens and focuses the tool window
36+
return true
37+
}
38+
39+
private fun load(path: String, cacheKey: Int, flags: Int): Icon {
40+
return IconManager.getInstance()
41+
.loadRasterizedIcon(path, SarifFileType.javaClass.getClassLoader(), cacheKey, flags)
42+
}
43+
44+
override fun useNativeIcon(): Boolean = false
45+
46+
}

src/main/kotlin/com/github/adrienpessu/sarifviewer/toolWindow/SarifViewerWindowFactory.kt

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import com.intellij.openapi.project.DumbService
2828
import com.intellij.openapi.project.Project
2929
import com.intellij.openapi.ui.ComboBox
3030
import com.intellij.openapi.vfs.VirtualFile
31+
import com.intellij.openapi.vfs.VirtualFileManager
32+
import com.intellij.openapi.ui.SimpleToolWindowPanel
3133
import com.intellij.openapi.wm.ToolWindow
3234
import com.intellij.openapi.wm.ToolWindowFactory
3335
import com.intellij.psi.search.FilenameIndex
@@ -79,7 +81,7 @@ class SarifViewerWindowFactory : ToolWindowFactory {
7981

8082
override fun shouldBeAvailable(project: Project) = true
8183

82-
class MyToolWindow(toolWindow: ToolWindow) {
84+
class MyToolWindow(toolWindow: ToolWindow) : SimpleToolWindowPanel(false, true) {
8385

8486
init {
8587
val actionManager = ActionManager.getInstance()
@@ -91,8 +93,8 @@ class SarifViewerWindowFactory : ToolWindowFactory {
9193
val actions = ArrayList<AnAction>()
9294
actions.add(openLocalFileAction)
9395
actions.add(refreshAction)
94-
9596
toolWindow.setTitleActions(actions)
97+
//configureToolbar()
9698
}
9799

98100
internal var github: GitHubInstance? = null
@@ -120,7 +122,18 @@ class SarifViewerWindowFactory : ToolWindowFactory {
120122
private var cacheSarif: SarifSchema210? = null
121123
private var currentLeaf: Leaf? = null
122124

123-
fun getContent() = JBPanel<JBPanel<*>>().apply {
125+
public fun openFile(project : Project, file : File) {
126+
val extractSarifFromFile = extractSarifFromFile(file)
127+
treeBuilding(extractSarifFromFile)
128+
localMode = true
129+
}
130+
131+
override fun getContent(): JComponent? {
132+
configureToolbar()
133+
return this.component
134+
}
135+
136+
private fun configureToolbar() {
124137

125138
manageTreeIcons()
126139
buildSkeleton()
@@ -160,7 +173,7 @@ class SarifViewerWindowFactory : ToolWindowFactory {
160173
})
161174
}
162175

163-
private fun JBPanel<JBPanel<*>>.loadDataAndUI(
176+
private fun loadDataAndUI(
164177
repository: GitRepository,
165178
selectedCombo: BranchItemComboBox? = null
166179
) {
@@ -262,7 +275,7 @@ class SarifViewerWindowFactory : ToolWindowFactory {
262275
thisLogger().info(message)
263276
}
264277

265-
private fun JBPanel<JBPanel<*>>.buildSkeleton() {
278+
private fun buildSkeleton() {
266279
steps.layout = BoxLayout(steps, BoxLayout.Y_AXIS)
267280
tableSteps.size = Dimension(steps.width, steps.height)
268281
steps.add(tableSteps)
@@ -446,7 +459,13 @@ class SarifViewerWindowFactory : ToolWindowFactory {
446459
myList.addTreeSelectionListener(object : TreeSelectionListener {
447460
override fun valueChanged(e: TreeSelectionEvent?) {
448461
if (e != null && e.isAddedPath) {
449-
val leaves = map[e.path.parentPath.lastPathComponent.toString().split(" ").first()]
462+
val key = e.path.parentPath.lastPathComponent.toString()
463+
// path (count)
464+
val leaves1 = map[key.split(" ").first()]
465+
// bug desc (count)
466+
val leaves2 = map[key.substring(0, key.lastIndexOf(' '))]
467+
val leaves = (leaves1.orEmpty() + leaves2.orEmpty()).takeIf { it.isNotEmpty() }
468+
450469
if (!leaves.isNullOrEmpty()) {
451470
currentLeaf = try {
452471
leaves.first { it.address == ((e.path.lastPathComponent as DefaultMutableTreeNode).userObject as Leaf).address }

src/main/resources/META-INF/plugin.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
<depends>com.intellij.modules.platform</depends>
88
<depends>Git4Idea</depends>
9+
<depends>com.intellij.modules.json</depends>
910

1011
<resource-bundle>messages.MyBundle</resource-bundle>
1112

@@ -32,7 +33,10 @@
3233
<notificationGroup id="SARIF viewer"
3334
displayType="BALLOON"/>
3435
<codeVisionProvider language="kotlin" implementationClass="com.github.adrienpessu.sarifviewer.toolWindow.SarifCodeVisionProvider"/>
35-
36+
<fileType
37+
name="SARIF"
38+
implementationClass="com.github.adrienpessu.sarifviewer.SarifFileType"
39+
extensions="sarif" fieldName="INSTANCE" language="JSON"/>
3640
</extensions>
3741

3842

Lines changed: 8 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)