Skip to content
Snippets Groups Projects
Commit 006fb56a authored by Etxaniz Errazkin, Iñaki's avatar Etxaniz Errazkin, Iñaki
Browse files

y1 commit

parents
Branches y1
Tags
No related merge requests found
Showing
with 847 additions and 0 deletions
Source Code/PiacereIDEIntegration.KR06And07/Piacere/PiacereIcon_16x16.png

2.02 KiB

source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
Piacere/
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.preferencePages">
<page
category="PiacereToolCustomization.preferences.page1"
class="eu.piacere.ide.toolIntegration.kr06And07.preferencePage.KR06And07PreferencePage"
id="PiacereIDEIntegration.KR06And07.preferences.page1"
name="IaC Security Inspector Preferences">
</page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="eu.piacere.ide.toolIntegration.kr06And07.preferencePage.KR06And07PreferenceInitializer">
</initializer>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
categoryId="eu.piacere.piacereModelsCommands.category.id"
defaultHandler="eu.piacere.ide.toolIntegration.kr06And07.commandHandlers.IaCSecurityInspectorCommandHandler"
id="eu.piacere.piacereModelsCommands.IaCSecurityInspectorCommand.id"
name="Security Inspector">
</command>
<!-- <command
categoryId="eu.piacere.piacereModelsCommands.category.id"
defaultHandler="eu.piacere.ide.toolIntegration.kr06And07.commandHandlers.IaCSecurityEnableCommandHandler"
id="eu.piacere.piacereModelsCommands.IaCSecurityEnableCommand.id"
name="Security Enable">
</command>
<command
categoryId="eu.piacere.piacereModelsCommands.category.id"
defaultHandler="eu.piacere.ide.toolIntegration.kr06And07.commandHandlers.IaCSecurityConfCommandHandlers"
id="eu.piacere.piacereModelsCommands.IaCSecurityConfCommand.id"
name="Security configuration">
</command> -->
<command
categoryId="eu.piacere.piacereModelsCommands.category.id"
defaultHandler="eu.piacere.ide.toolIntegration.kr06And07.commandHandlers.IaCSecurityScanCommandHandler"
id="eu.piacere.piacereModelsCommands.IaCSecurityScanCommand.id"
name="Security Scanner">
</command>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="menu:org.eclipse.ui.main.menu">
<menu
id="piacereMenu"
label="Piacere">
<menu
label="Security Inspector">
<command
commandId="eu.piacere.piacereModelsCommands.IaCSecurityInspectorCommand.id"
label="Get Security Inspector Configuration"
style="push"
tooltip="Checks your IaC for security vulnerabilities">
</command>
<!--<command
commandId="eu.piacere.piacereModelsCommands.IaCSecurityConfCommand.id"
label="Set Security Configuration"
style="push"
tooltip="Set Security Configuration">
</command>
<command
commandId="eu.piacere.piacereModelsCommands.IaCSecurityEnableCommand.id"
label="Enable/Disable Security Checks"
style="push"
tooltip="Enable/Disable your IaC or Components">
</command>-->
</menu>
</menu>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:eu.piacere.eclipsePopupMenu.id">
<command
commandId="eu.piacere.piacereModelsCommands.IaCSecurityScanCommand.id"
icon="Piacere/PiacereIcon_16x16.png"
label="Perform Security Scan"
style="push"
tooltip="Scan IaC for security vulnerabilities">
<visibleWhen
checkEnabled="false">
<or>
<reference
definitionId="eu.piacere.piacereTool.propertyTesters.extensionPropertyTester.isTarGz.id">
</reference>
<reference
definitionId="eu.piacere.piacereTool.propertyTesters.extensionPropertyTester.isZip.id">
</reference>
<reference
definitionId="eu.piacere.piacereTool.propertyTesters.extensionPropertyTester.isCSAR.id">
</reference>
</or>
</visibleWhen>
</command>
</menuContribution>
</extension>
</plugin>
package eu.piacere.ide.toolIntegration.kr06And07.commandHandlers;
import java.io.File;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPatch;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.json.JSONException;
import org.json.JSONObject;
import org.osgi.framework.FrameworkUtil;
import eu.piacere.piacereTool.utils.FileUtils;
import eu.piacere.piacereTool.utils.ToolCustomizationUtils;
public class IaCSecurityConfCommandHandler extends AbstractHandler {
private String getPreference(String preferenceID) {
ScopedPreferenceStore scopedPreferenceStore = new ScopedPreferenceStore(ConfigurationScope.INSTANCE,(FrameworkUtil.getBundle(IaCSecurityConfCommandHandler.class)).getSymbolicName());
return scopedPreferenceStore.getString(preferenceID);
}
private JSONObject showDialog(IPath fileuri) throws ClientProtocolException, IOException, JSONException {
JFrame frame = new JFrame("Security Options");
String result = (String)JOptionPane.showInputDialog(
frame,
"Configure IaC/Component",
"Check Name",
JOptionPane.PLAIN_MESSAGE,
null,
null,
""
);
if(result == null) return null;
String result2 = (String)JOptionPane.showInputDialog(
frame,
"Configure IaC/Component",
"Secret",
JOptionPane.PLAIN_MESSAGE,
null,
null,
""
);
if(result2 == null) return null;
return doPostRequestTochecker(fileuri, result, result2);
}
private JSONObject doPostRequestTochecker(IPath fileuri, String chk_name, String secret) throws ClientProtocolException, IOException, JSONException {
HttpClient httpClient = HttpClientBuilder.create().build();
String url=getPreference("KR06.protocol")+"://"+getPreference("KR06.host")+":"+getPreference("KR06.port")+"/checks/";
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(!chk_name.equals("")) {
url+= chk_name + "/configure?";
}
if(!secret.equals("")) {
builder.addTextBody("secret", secret);
}
if(!fileuri.equals("")) {
builder.addPart("config_file", new FileBody(new File(fileuri.toString()), ContentType.DEFAULT_BINARY));
}
HttpPatch httpPatch = new HttpPatch(url);
HttpEntity entity = builder.build();
httpPatch.setEntity(entity);
CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(httpPatch);
if(response.getStatusLine().getStatusCode()==200) {
String content = EntityUtils.toString(response.getEntity());
ToolCustomizationUtils.showInformationDialog("Security Configure Result", content);
} else {
String content = EntityUtils.toString(response.getEntity());
ToolCustomizationUtils.showErrorDialog("Security Configure Error", content);
}
return null;
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ToolCustomizationUtils.saveWorkbench();
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof StructuredSelection) {
if(((StructuredSelection)selection).getFirstElement() instanceof IFile){
IFile res = (IFile)((StructuredSelection) selection).getFirstElement();
IProject project = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(ToolCustomizationUtils.getFullPath(URI.createURI(res.getLocationURI().toString()))).getProject();
//DOMLModel theDOMLModel = (DOMLModel) ModelUtils.loadEMFModelRoot(res);
String fileContent=FileUtils.getIFileContents(res);
IPath path = res.getLocation();
if(fileContent==null) {
//ARROJAR ERROR
return null;
}
JSONObject responseFromChecker=null;
try {
// Escollir 1 desde la finestra emergent
responseFromChecker=showDialog(path);
} catch (IOException | JSONException e2) {
e2.printStackTrace();
}
return null;
}
}
return null;
}
}
package eu.piacere.ide.toolIntegration.kr06And07.commandHandlers;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPatch;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.json.JSONException;
import org.osgi.framework.FrameworkUtil;
import eu.piacere.piacereTool.utils.ToolCustomizationUtils;
public class IaCSecurityEnableCommandHandler extends AbstractHandler{
String url = "";
private String getPreference(String preferenceID) {
ScopedPreferenceStore scopedPreferenceStore = new ScopedPreferenceStore(ConfigurationScope.INSTANCE,(FrameworkUtil.getBundle(IaCSecurityInspectorCommandHandler.class)).getSymbolicName());
return scopedPreferenceStore.getString(preferenceID);
}
private String showDialog() throws ClientProtocolException, IOException, JSONException {
String[] options = {"true", "false"};
JFrame frame = new JFrame("Security Options");
String result = (String)JOptionPane.showInputDialog(
frame,
"Enable IaC/Component",
"Check Name",
JOptionPane.PLAIN_MESSAGE,
null,
null,
""
);
if(result == null) return null;
String result2 = (String)JOptionPane.showInputDialog(
frame,
"Select one option",
"Enable IaC/Component",
JOptionPane.PLAIN_MESSAGE,
null,
options,
options[0]
);
if(result2 == null) return null;
return doPatchRequestToChecker(result, result2);
}
private String doPatchRequestToChecker(String chk_name, String enable) throws ClientProtocolException, IOException, JSONException {
HttpClient httpClient = HttpClientBuilder.create().build();
url=getPreference("KR06.protocol")+"://"+getPreference("KR06.host")+":"+getPreference("KR06.port")+"/checks/";
if(!chk_name.equals("")) {
url+= chk_name + "/";
}
if(enable.equals("true")) {
url+= "enable";
} else {
url+= "disable";
}
HttpPatch httpPatch = new HttpPatch(url);
httpPatch.setHeader("Accept", "application/json");
CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(httpPatch);
if(response.getStatusLine().getStatusCode()==200) {
String content = EntityUtils.toString(response.getEntity());
ToolCustomizationUtils.showInformationDialog("Security Enable Result", content);
} else {
String content = EntityUtils.toString(response.getEntity());
ToolCustomizationUtils.showErrorDialog("Security Enable Error", content);
}
return null;
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
/*try {
// Escollir 1 desde la finestra emergent
String responseFromChecker=showDialog();
} catch (IOException | JSONException e2) {
e2.printStackTrace();
}*/
return null;
}
}
package eu.piacere.ide.toolIntegration.kr06And07.commandHandlers;
import java.io.IOException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import eu.piacere.piacereTool.utils.ToolCustomizationUtils;
public class IaCSecurityInspectorCommandHandler extends AbstractHandler {
private JSONArray showDialog() throws ClientProtocolException, IOException, JSONException {
String keyword=ToolCustomizationUtils.doDialogAskWithoutPostProcess("Keyword","Keyword","");
if(keyword==null) {
return null;
}
return doGetRequestToChecker(keyword);
}
private JSONArray doGetRequestToChecker(String keyword/*, String configured, String enabled, String target_entity*/) throws ClientProtocolException, IOException, JSONException {
String url=ToolCustomizationUtils.getPreference(this.getClass(), "KR06_07.protocol")+"://"+ToolCustomizationUtils.getPreference(this.getClass(), "KR06_07.host")+":"+ToolCustomizationUtils.getPreference(this.getClass(), "KR06_07.port")+"/checks?";
String target_entity=ToolCustomizationUtils.getPreference(this.getClass(), "KR06_07.entityType");
if(!target_entity.equals("both")) {
url+= "target_entity_type=" + target_entity+"&";
}
if(!keyword.equals("")) {
url+= "keyword=" + keyword+"&";
}
String enabled=ToolCustomizationUtils.getPreference(this.getClass(), "KR06_07.enableStatus");
if(!enabled.equals("both")) {
url+= "enabled=" + enabled+"&";
}
String configured=ToolCustomizationUtils.getPreference(this.getClass(), "KR06_07.confStatus");
if(!configured.equals("both")) {
url+= "configured=" + configured;
}
HttpGet httpGet = new HttpGet(url);
HttpClient httpClient = HttpClientBuilder.create().build();
CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(httpGet);
if(response.getStatusLine().getStatusCode()==200) {
String content = EntityUtils.toString(response.getEntity());
JSONArray responseAsJSON=new JSONArray(content);
return responseAsJSON;
}
return null;
}
private String capitalize(String str) {
if(str == null || str.isEmpty()) {
return str;
}
return str.substring(0, 1).toUpperCase() + str.substring(1);
}
/*
private JSONObject doPostRequestToScanner(String fileContent, List<String> checks) throws ClientProtocolException, IOException, JSONException {
HttpClient httpClient = HttpClientBuilder.create().build();
url=getPreference("KR06.protocol")+"://"+getPreference("KR06.host")+":"+getPreference("KR06.port")+"/scan?checks=" + checks + "&iac=" + fileContent;
HttpPost httpPost = new HttpPost();
StringEntity entity = new StringEntity(fileContent);
httpPost.setEntity(entity);
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Content-type","multipart/form-data");
CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(httpPost);
if(response.getStatusLine().getStatusCode()==200) {
String content = EntityUtils.toString(response.getEntity());
JSONObject responseAsJSON = new JSONObject(content);
return responseAsJSON;
}
return null;
}
private JSONObject doPatchEnableRequestToChecker(String check_name) throws ClientProtocolException, IOException, JSONException {
HttpClient httpClient = HttpClientBuilder.create().build();
url=getPreference("KR06.protocol")+"://"+getPreference("KR06.host")+":"+getPreference("KR06.port")+"/checks/"+ check_name + "/enable";
HttpPatch httpPatch = new HttpPatch();
httpPatch.setHeader("Accept", "application/json");
CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(httpPatch);
if(response.getStatusLine().getStatusCode()==200) {
String content = EntityUtils.toString(response.getEntity());
JSONObject responseAsJSON = new JSONObject(content);
return responseAsJSON;
}
return null;
}
private JSONObject doPatchDisableRequestToChecker(String check_name) throws ClientProtocolException, IOException, JSONException {
HttpClient httpClient = HttpClientBuilder.create().build();
url=getPreference("KR06.protocol")+"://"+getPreference("KR06.host")+":"+getPreference("KR06.port")+"/checks/"+ check_name + "/disable";
HttpPatch httpPatch = new HttpPatch();
httpPatch.setHeader("Accept", "application/json");
CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(httpPatch);
if(response.getStatusLine().getStatusCode()==200) {
String content = EntityUtils.toString(response.getEntity());
JSONObject responseAsJSON = new JSONObject(content);
return responseAsJSON;
}
return null;
}
private JSONObject doPatchConfigureRequestToChecker(String fileContent, String check_name, String secret) throws ClientProtocolException, IOException, JSONException {
HttpClient httpClient = HttpClientBuilder.create().build();
url=getPreference("KR06.protocol")+"://"+getPreference("KR06.host")+":"+getPreference("KR06.port")+"/checks/" + check_name + "/configure?config_file=" + fileContent + "&secret=" + secret;
HttpPatch httpPatch = new HttpPatch();
StringEntity entity = new StringEntity(fileContent);
httpPatch.setEntity(entity);
httpPatch.setHeader("Accept", "application/json");
httpPatch.setHeader("Content-type","multipart/form-data");
CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(httpPatch);
if(response.getStatusLine().getStatusCode()==200) {
String content = EntityUtils.toString(response.getEntity());
JSONObject responseAsJSON = new JSONObject(content);
return responseAsJSON;
}
return null;
}
*/
private void interpretResult(JSONArray responseFromSchecker) {
String response = "";
try {
for (int i= 0; i < responseFromSchecker.length(); i++) {
JSONObject jsonobj = responseFromSchecker.getJSONObject(i);
String name = jsonobj.getString("name");
if(jsonobj.getBoolean("enabled")) {
response += "- "+capitalize(jsonobj.getString("target_entity_type"))+" "+ name + " IS enabled. \n";
}
else {
response += "- "+capitalize(jsonobj.getString("target_entity_type"))+" "+ name + " IS NOT enabled. \n";
}
if(jsonobj.getBoolean("configured")) {
response += "- "+capitalize(jsonobj.getString("target_entity_type"))+" "+ name + " IS configured. \n";
}
else {
response += "- "+capitalize(jsonobj.getString("target_entity_type"))+" "+ name + " IS NOT configured. \n";
}
}
} catch (JSONException e) {
e.printStackTrace();
}
ToolCustomizationUtils.showInformationDialog("Security Inspector Configuration", response);
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
JSONArray responseFromChecker = null;
try {
responseFromChecker=showDialog();
} catch (IOException | JSONException e2) {
e2.printStackTrace();
}
if(responseFromChecker==null) {
//ARROJAR ERROR
return null;
}else {
interpretResult(responseFromChecker);
}
return null;
}
}
\ No newline at end of file
package eu.piacere.ide.toolIntegration.kr06And07.commandHandlers;
import java.io.File;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
import org.json.JSONException;
import org.json.JSONObject;
import eu.piacere.piacereTool.utils.FileUtils;
import eu.piacere.piacereTool.utils.ToolCustomizationUtils;
public class IaCSecurityScanCommandHandler extends AbstractHandler {
private String showDialog() throws ClientProtocolException, IOException, JSONException {
String checks=ToolCustomizationUtils.doDialogAskWithoutPostProcess("Perform Security Scan","Provide a comma-separated list of the Components/IaC you want to scan (leave blank for a whole scan)","");
return checks;
}
private JSONObject doPostRequestTochecker(IPath fileuri, String checks) throws ClientProtocolException, IOException, JSONException {
HttpClient httpClient = HttpClientBuilder.create().build();
String url=ToolCustomizationUtils.getPreference(this.getClass(), "KR06_07.protocol")+"://"+ToolCustomizationUtils.getPreference(this.getClass(), "KR06_07.host")+":"+ToolCustomizationUtils.getPreference(this.getClass(), "KR06_07.port")+"/scan";
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
if(!checks.equals("")) {
String aux = checks.replace(" ", ",");
while(aux.contains(",,")) {
aux = aux.replace(",,", ",");
}
builder.addTextBody("checks", aux);
}
builder.addPart("iac", new FileBody(new File(fileuri.toString()), ContentType.DEFAULT_BINARY));
HttpPost httpPost = new HttpPost(url);
HttpEntity entity = builder.build();
httpPost.setEntity(entity);
CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(httpPost);
if(response.getStatusLine().getStatusCode()==200) {
String content = EntityUtils.toString(response.getEntity());
JSONObject reponseResult = new JSONObject(content);
ToolCustomizationUtils.showInformationDialog("Model Scanned", "Your Model was Scanned successfully");
return reponseResult;
} else {
String content = EntityUtils.toString(response.getEntity());
ToolCustomizationUtils.showErrorDialog("Security Scan Error", content);
}
return null;
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ToolCustomizationUtils.saveWorkbench();
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof StructuredSelection) {
if(((StructuredSelection)selection).getFirstElement() instanceof IFile){
IFile res = (IFile)((StructuredSelection) selection).getFirstElement();
IPath path = res.getLocation();
JSONObject responseFromScaner=null;
try {
String checks=showDialog();
if(checks!=null) {
responseFromScaner=doPostRequestTochecker(path, checks);
if(responseFromScaner!=null) {
saveFileInWorkspace(res.getParent(), path ,responseFromScaner.toString(4));
}
}
}
catch (JSONException|IOException e) {
e.printStackTrace();
}
}
}
return null;
}
private void saveFileInWorkspace(IContainer container, IPath path, String fileContent) {
ProgressMonitorDialog pd=new ProgressMonitorDialog(ToolCustomizationUtils.getActiveShell());
pd.open();
try {
FileUtils.createFile(path.lastSegment().split(".tar")[0]+".scannresult_"+FileUtils.getTimestamp()+".json", container, fileContent, pd);
} catch (Exception e1) {
e1.printStackTrace();
}
pd.close();
try {
container.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
e.printStackTrace();
}
}
}
package eu.piacere.ide.toolIntegration.kr06And07.preferencePage;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.FrameworkUtil;
public class KR06And07PreferenceInitializer extends AbstractPreferenceInitializer {
@Override
public void initializeDefaultPreferences() {
ScopedPreferenceStore scopedPreferenceStore = new ScopedPreferenceStore(ConfigurationScope.INSTANCE,(FrameworkUtil.getBundle(KR06And07PreferenceInitializer.class)).getSymbolicName());
scopedPreferenceStore.setDefault("KR06_07.host", "isr.ci.piacere.digital.tecnalia.dev");
scopedPreferenceStore.setDefault("KR06_07.port", 443);
scopedPreferenceStore.setDefault("KR06_07.protocol", "https");
scopedPreferenceStore.setDefault("KR06_07.enableStatus", "both");
scopedPreferenceStore.setDefault("KR06_07.confStatus", "both");
scopedPreferenceStore.setDefault("KR06_07.entityType", "both");
}
}
package eu.piacere.ide.toolIntegration.kr06And07.preferencePage;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.FrameworkUtil;
public class KR06And07PreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
public KR06And07PreferencePage() {
super(GRID);
}
@Override
public void init(IWorkbench workbench) {
//WHICH SCOPE SHOULD I SELECT: https://wiki.eclipse.org/FAQ_What_is_a_preference_scope%3F
setPreferenceStore(new ScopedPreferenceStore(ConfigurationScope.INSTANCE, (FrameworkUtil.getBundle(KR06And07PreferenceInitializer.class)).getSymbolicName()));
setDescription("These Are The IaC Security Inspector Preferences");
}
@Override
protected void createFieldEditors() {
addField(new StringFieldEditor("KR06_07.host", "Endpoint Host:", getFieldEditorParent()));
addField(new IntegerFieldEditor("KR06_07.port", "Endpoint Port:", getFieldEditorParent()));
addField(new RadioGroupFieldEditor("KR06_07.protocol", "Protocol:", 1, new String[][] {{"HTTP","http"},{"HTTPS","https"}}, getFieldEditorParent()));
addField(new RadioGroupFieldEditor("KR06_07.enableStatus", "Enabled:", 1, new String[][] {{"Both Enabled and Disabled Checks","both"}, {"Only Enabled Checks","true"}, {"Only Disabled Checks","false"}}, getFieldEditorParent()));
addField(new RadioGroupFieldEditor("KR06_07.confStatus", "Configured:", 1, new String[][] {{"Both Configured and Not Configured Checks","both"}, {"Only Configured Checks","true"}, {"Only Not Configured Checks","false"}}, getFieldEditorParent()));
addField(new RadioGroupFieldEditor("KR06_07.entityType", "Entity Type:", 1, new String[][] {{"Both IaC and Component Checks","both"}, {"Only IaC","IaC"}, {"Only Component","component"}}, getFieldEditorParent()));
}
}
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/bin/
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PiacereIDEIntegration.KR08</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: KR08
Bundle-SymbolicName: PiacereIDEIntegration.KR08;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: PiacereIDEIntegration.KR08
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.apache.httpcomponents.httpcore
Import-Package: eu.piacere.doml.doml.commons,
eu.piacere.piacereTool.utils,
org.apache.commons.io,
org.apache.http.client;version="4.5.13",
org.apache.http.client.methods;version="4.5.13",
org.apache.http.impl.client;version="4.5.13",
org.eclipse.core.resources,
org.eclipse.core.runtime.preferences;version="3.4.0",
org.eclipse.emf.common.notify,
org.eclipse.emf.common.util,
org.eclipse.emf.ecore,
org.eclipse.emf.ecore.resource,
org.eclipse.emf.ecore.resource.impl,
org.eclipse.emf.ecore.util,
org.eclipse.emf.edit.provider.resource,
org.eclipse.emf.edit.ui.provider,
org.eclipse.ui.dialogs,
org.eclipse.ui.navigator,
org.eclipse.ui.views.properties,
org.json,
org.restlet,
org.restlet.data,
org.restlet.representation,
org.restlet.resource
Source Code/PiacereIDEIntegration.KR08/Piacere/PiacereIcon_16x16.png

2.02 KiB

source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
Piacere/,\
plugin.xml,\
icons/
Source Code/PiacereIDEIntegration.KR08/icons/ComponentsModel.png

1.83 KiB

Source Code/PiacereIDEIntegration.KR08/icons/FAdAIcon_24.png

2.23 KiB

Source Code/PiacereIDEIntegration.KR08/icons/FadaModelRepositoriesView.png

1.91 KiB

Source Code/PiacereIDEIntegration.KR08/icons/FadaModelRepositoriesView_old.png

2.14 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment