public static boolean isBackendReadWrite() { return ConnectType.READ_WRITE.equals(getBackendConnectType()); }
public static boolean isUploadEnabled() { //return VulasConfiguration.getSingleton().getConfiguration().getBoolean(UPLOAD_ENABLED, false); return isBackendReadWrite(); }
private DynamicTransformer() throws IllegalStateException { this.instrControl = InstrumentationControl.getInstance(this.getClass().getSimpleName()); try { if(!CoreConfiguration.existsInBackend(CoreConfiguration.getAppContext())) throw new IllegalStateException("Application " + CoreConfiguration.getAppContext() + " does not exist in backend"); } catch (ConfigurationException e) { throw new IllegalStateException("Error while reading configuration: " + e.getMessage()); } // Freeze a couple of classes this.freezeClasses(); }
/** * Uploads trace information collected during JVM execution to the central collector. * If batch size is equal to -1, all traces will be uploaded. */ private synchronized void uploadTraces(int _batch_size) { if(this.constructUsage.isEmpty()) TraceCollector.getLog().info("No traces collected"); else { try { BackendConnector.getInstance().uploadTraces(CoreConfiguration.buildGoalContextFromGlobalConfiguration(), CoreConfiguration.getAppContext(), this.toJSON(_batch_size)); } catch (Exception e) { this.getLog().error("Error while uploaded traces: " + e.getMessage()); } } }
app = CoreConfiguration.getAppContext(); VulasConfiguration.getGlobal().setPropertyIfEmpty(CoreConfiguration.APP_CTX_ARTIF, this.project.getArtifactId()); VulasConfiguration.getGlobal().setPropertyIfEmpty(CoreConfiguration.APP_CTX_VERSI, this.project.getVersion()); app = CoreConfiguration.getAppContext();
this.agentOptions.put(CoreConfiguration.BACKEND_CONNECT, CoreConfiguration.ConnectType.READ_ONLY.toString()); getLog().info("Setting [" + CoreConfiguration.BACKEND_CONNECT + "] set to [" + CoreConfiguration.ConnectType.READ_ONLY + "] (hard-coded, no matter the configured value)");
public static final boolean existsInBackend(Application _app) { boolean exists = false; try { exists = BackendConnector.getInstance().isAppExisting(CoreConfiguration.buildGoalContextFromGlobalConfiguration(), _app); } catch (BackendConnectionException e) { log.error("Error while checking whether " + _app + " exists in backend: " + e.getMessage()); } return exists; }
public ConstructChange(String _repo, String _repo_path, Construct _def, Construct _fix, String _rev, String _time_stamp) { if(_def==null && _fix==null) throw new IllegalArgumentException("At least one construct must be provided (defective, fixed or both)"); this.repo = _repo; this.repoPath = _repo_path; this.def = _def; this.fix = _fix; this.commit = (_rev!=null&&_rev.contains(":"))?_rev.substring(0,_rev.indexOf(":")-1):_rev; this.committedAt = _time_stamp; // Signatures of the defective and fixed constructs (if any, can be null) and the so-called signature change final SignatureFactory factory = CoreConfiguration.getSignatureFactory( com.sap.psr.vulas.ConstructId.toSharedType( (_def!=null ? _def.getId() : _fix.getId()) )); if(factory!=null) { defSignature = factory.createSignature(def); fixSignature = factory.createSignature(fix); signatureChange = factory.computeChange(def, fix); } }
if( (!this.isUploadRequest() && !CoreConfiguration.isBackendOffline() ) || (this.isUploadRequest() && exception==null && CoreConfiguration.isBackendReadWrite()) ) { try { response = this.sendRequest(); if(this.isUploadRequest() && !this.isPayloadSavedOnDisk() && (exception!=null || !CoreConfiguration.isBackendReadWrite())) { try { this.saveToDisk();
public static URI getUri(Service _service, String _path, Map<String,String> _params) { if(!CoreConfiguration.isBackendOffline() && !VulasConfiguration.getGlobal().hasServiceUrl(_service)) throw new IllegalStateException("URL for service [" + _service + "] is not configured");
b.append(",\"goal\":\"").append(this.goalType).append("\""); b.append(",\"startedAtClient\":\"").append(StringUtil.formatDate(this.stopWatch.getStartMillis())).append("\""); b.append(",\"clientVersion\":").append(JsonBuilder.escape(CoreConfiguration.getVulasRelease()));
if(CoreConfiguration.isMaxItemsCollected(tpi.getTouchPoints().size())) return;
public StackTraceInstrumentor() { try { final Map<String, Set<com.sap.psr.vulas.shared.json.model.ConstructId>> bug_change_lists = BackendConnector.getInstance().getAppBugs(CoreConfiguration.buildGoalContextFromGlobalConfiguration(), CoreConfiguration.getAppContext()); this.constructsCollectStacktrace = AbstractTraceInstrumentor.merge(bug_change_lists); } catch (ConfigurationException e) { StackTraceInstrumentor.log.error("Error during instantiation: " + e.getMessage()); throw new IllegalStateException("Error during instantiation: " + e.getMessage(), e); } catch (IllegalStateException e) { StackTraceInstrumentor.log.error("Error during instantiation: " + e.getMessage()); throw new IllegalStateException("Error during instantiation: " + e.getMessage(), e); } catch (BackendConnectionException e) { StackTraceInstrumentor.log.error("Error during instantiation: " + e.getMessage()); throw new IllegalStateException("Error during instantiation: " + e.getMessage(), e); } }
public static boolean isBackendOffline() { return ConnectType.OFFLINE.equals(getBackendConnectType()); } public static boolean isBackendReadOnly() { return ConnectType.READ_ONLY.equals(getBackendConnectType()); }
public ExecutionMonitor() { try { final Application app_ctx = CoreConfiguration.getAppContext(); final Configuration cfg = VulasConfiguration.getGlobal().getConfiguration(); // Always create and register shutdown uploader this.shutdownUploader = new UploadScheduler(this); Runtime.getRuntime().addShutdownHook(new Thread(this.shutdownUploader, "vulas-shutdown-trace-upload")); // Configure uploader: Create and start periodic uploader according to configuration if(cfg.getBoolean(CoreConfiguration.MONI_PERIODIC_UPL_ENABLED, true)) this.enablePeriodicUpload(cfg.getInt(CoreConfiguration.MONI_PERIODIC_UPL_INTERVAL, 300000), cfg.getInt(CoreConfiguration.MONI_PERIODIC_UPL_BATCH_SIZE, 1000)); // Goal execution this.exe = new TestGoal(); this.exe.setGoalClient(GoalClient.AGENT); this.startGoal(); } catch(ConfigurationException ce) { ExecutionMonitor.getLog().error(ce.getMessage()); } catch(GoalConfigurationException gce) { ExecutionMonitor.getLog().error(gce.getMessage()); } }
if(CoreConfiguration.isBackendOffline()) { ConditionalHttpRequest.log.info("Condition(s) not evaluated due to offline mode, do " + this.toString()); return super.send();
private ConstructIdUtil() { try { final Set<com.sap.psr.vulas.shared.json.model.ConstructId> app_constructs = BackendConnector.getInstance().getAppConstructIds(CoreConfiguration.buildGoalContextFromGlobalConfiguration(), CoreConfiguration.getAppContext()); this.appConstructs = new HashSet<ConstructId>(); for(com.sap.psr.vulas.shared.json.model.ConstructId cid: app_constructs) { this.appConstructs.add(JavaId.toCoreType(cid)); } } catch (ConfigurationException e) { ConstructIdUtil.getLog().error(e.getMessage(), e); } catch (BackendConnectionException e) { ConstructIdUtil.getLog().error(e.getMessage(), e); } }
public static boolean isBackendReadOnly() { return ConnectType.READ_ONLY.equals(getBackendConnectType()); } public static boolean isBackendReadWrite() { return ConnectType.READ_WRITE.equals(getBackendConnectType()); }
app = CoreConfiguration.getAppContext(); VulasConfiguration.getGlobal().setPropertyIfEmpty(CoreConfiguration.APP_CTX_ARTIF, this.project.getArtifactId()); VulasConfiguration.getGlobal().setPropertyIfEmpty(CoreConfiguration.APP_CTX_VERSI, this.project.getVersion()); app = CoreConfiguration.getAppContext();
public SingleStackTraceInstrumentor() { this.maxStacktraces = VulasConfiguration.getGlobal().getConfiguration().getInt(CoreConfiguration.INSTR_MAX_STACKTRACES, 10); try { final Map<String, Set<com.sap.psr.vulas.shared.json.model.ConstructId>> bug_change_lists = BackendConnector.getInstance().getAppBugs(CoreConfiguration.buildGoalContextFromGlobalConfiguration(), CoreConfiguration.getAppContext()); this.constructsCollectStacktrace = AbstractTraceInstrumentor.merge(bug_change_lists); } catch (ConfigurationException e) { SingleStackTraceInstrumentor.log.error("Error during instantiation: " + e.getMessage()); throw new IllegalStateException("Error during instantiation: " + e.getMessage(), e); } catch (IllegalStateException e) { SingleStackTraceInstrumentor.log.error("Error during instantiation: " + e.getMessage()); throw new IllegalStateException("Error during instantiation: " + e.getMessage(), e); } catch (BackendConnectionException e) { SingleStackTraceInstrumentor.log.error("Error during instantiation: " + e.getMessage()); throw new IllegalStateException("Error during instantiation: " + e.getMessage(), e); } }