eric7/CycloneDXInterface/CycloneDXConfigDialog.py

branch
eric7
changeset 9119
5bcdef5207f6
parent 9117
c6afba2049cf
child 9122
ddf8ed8f7387
--- a/eric7/CycloneDXInterface/CycloneDXConfigDialog.py	Sat Jun 04 11:56:48 2022 +0200
+++ b/eric7/CycloneDXInterface/CycloneDXConfigDialog.py	Sat Jun 04 15:53:41 2022 +0200
@@ -23,8 +23,18 @@
     Class implementing a dialog to configure the CycloneDX SBOM generation.
     """
     SupportedSchemas = {
-        "JSON": ["1.4", "1.3", "1.2"],
-        "XML": ["1.4", "1.3", "1.2", "1.1", "1.0"],
+        "JSON": [
+            (1, 4),
+            (1, 3),
+            (1, 2),
+        ],
+        "XML": [
+            (1, 4),
+            (1, 3),
+            (1, 2),
+            (1, 1),
+            (1, 0),
+        ],
     }
     Sources = {
         "pipenv": "Pipfile.lock",
@@ -72,6 +82,9 @@
             CycloneDXConfigDialog.Sources["requirements"]
         )))
         
+        self.vulnerabilityCheckBox.toggled.connect(
+            self.__repopulateSchemaVersionComboBox)
+        
         self.filePicker.setMode(EricPathPickerModes.SAVE_FILE_OVERWRITE_MODE)
         self.filePicker.setDefaultDirectory(self.__defaultDirectory)
         
@@ -83,6 +96,24 @@
         msh = self.minimumSizeHint()
         self.resize(max(self.width(), msh.width()), msh.height())
     
+    @pyqtSlot()
+    def __repopulateSchemaVersionComboBox(self):
+        """
+        Private slot to repopulate the schema version selector.
+        """
+        fileFormat = self.fileFormatComboBox.currentText()
+        minSchemaVersion = (
+            (1, 4)
+            if self.vulnerabilityCheckBox.isChecked() else
+            (1, 0)
+        )
+        self.schemaVersionComboBox.clear()
+        self.schemaVersionComboBox.addItems(
+            "{0}.{1}".format(*f)
+            for f in CycloneDXConfigDialog.SupportedSchemas[fileFormat]
+            if f >= minSchemaVersion
+        )
+    
     @pyqtSlot(str)
     def on_fileFormatComboBox_currentTextChanged(self, fileFormat):
         """
@@ -92,9 +123,7 @@
         @type str
         """
         # re-populate the file schema combo box
-        self.schemaVersionComboBox.clear()
-        self.schemaVersionComboBox.addItems(
-            CycloneDXConfigDialog.SupportedSchemas[fileFormat])
+        self.__repopulateSchemaVersionComboBox()
         
         # set the file filter
         if fileFormat == "JSON":
@@ -111,9 +140,9 @@
         Public method to get the SBOM configuration data.
         
         @return tuple containing the input source, the input file name, the
-            file format, the schema version and the path of the SBOM file to
-            be written
-        @rtype tuple of (str, str, str, str, str)
+            file format, the schema version, the path of the SBOM file to be
+            written and a flag indicating to include vulnerability information
+        @rtype tuple of (str, str, str, str, str, bool)
         """
         if self.environmentButton.isChecked():
             inputSource = "environment"
@@ -154,4 +183,7 @@
                 # should not happen
                 sbomFile = None
         
-        return inputSource, inputFile, fileFormat, schemaVersion, sbomFile
+        return (
+            inputSource, inputFile, fileFormat, schemaVersion, sbomFile,
+            self.vulnerabilityCheckBox.isChecked(),
+        )

eric ide

mercurial