Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pathExpression: string | PathExpression): Promise {
const fileHits = await astUtils.findFileMatches(p, parserOrRegistry, globOptions, pathExpression);
const matches: SpringBootProjectStructure[] = [];
for (const fh of fileHits) {
// It's in the default package if no match found
const packageName: { name: string } = {
name: fh.file.extension === "java" ?
// TODO using package workaround for Antlr bug
((await packageInfo(p, fh.file.path)) || { fqn: "" }).fqn :
evaluateScalarValue(fh.fileNode, KotlinPackage) ||
"",
};
const appClass = fh.matches[0].$value;
if (packageName && appClass) {
logger.debug("Successful Spring Boot inference on %j: packageName '%s', '%s'",
p.id, packageName.name, appClass);
matches.push(new SpringBootProjectStructure(packageName.name, appClass, fh.file));
} else {
logger.debug("Unsuccessful Spring Boot inference on %j: packageName '%j', '%s'",
p.id, packageName, appClass);
}
}
return matches;
}
for (const fh of fileHits) {
// It's in the default package if no match found
const packageName: { name: string } = {
name: fh.file.extension === "java" ?
// TODO using package workaround for Antlr bug
((await packageInfo(p, fh.file.path)) || { fqn: "" }).fqn :
evaluateScalarValue(fh.fileNode, KotlinPackage) ||
"",
};
const appClass = fh.matches[0].$value;
if (packageName && appClass) {
logger.debug("Successful Spring Boot inference on %j: packageName '%s', '%s'",
p.id, packageName.name, appClass);
matches.push(new SpringBootProjectStructure(packageName.name, appClass, fh.file));
} else {
logger.debug("Unsuccessful Spring Boot inference on %j: packageName '%j', '%s'",
p.id, packageName, appClass);
}
}
return matches;
}
export const MaterialChangeToJavaRepo = pushTest("Material change to Java repo", async pci => {
const beforeSha: string = _.get(pci, "push.before.sha");
const changedFiles = await filesChangedSince(pci.project, beforeSha);
if (!changedFiles) {
logger.info("Cannot determine if change is material on %j: can't enumerate changed files", pci.id);
return true;
}
logger.debug(`MaterialChangeToJavaRepo: Changed files are [${changedFiles.join(",")}]`);
if (anyFileChangedWithExtension(changedFiles, FileToWatch)) {
logger.debug("Change is material on %j: changed files=[%s]", pci.id, changedFiles.join(","));
return true;
}
logger.debug("Change is immaterial on %j: changed files=[%s]", pci.id, changedFiles.join(","));
return false;
});
content: postingLogs || [],
},
headers: { "Content-Type": "application/json" },
retry: {
retries: 0,
},
options: {
timeout: 2500,
},
});
} catch (err) {
this.localLogs = postingLogs.concat(this.localLogs);
if (!/timeout.*exceeded/i.test(err.message)) {
logger.error(err.message);
} else {
logger.debug("Calling rolar timed out");
}
}
return result;
}
return Promise.resolve();
}
inspection: async (project, cri) => {
logger.debug("Running regexp review '%s' on %s against %j", name, opts.globPattern, antiPatterns);
const result: ProjectReview = {repoId: project.id, comments: []};
await projectUtils.doWithFiles(project, opts.globPattern, async f => {
const content = await f.getContent();
antiPatterns.forEach(problem => {
const rex = typeof problem.antiPattern === "string" ?
new RegExp(_.escapeRegExp(problem.antiPattern)) :
problem.antiPattern;
if (rex.test(content)) {
logger.debug("%s: Antipattern %s found in %s", name, problem.antiPattern, f.path);
result.comments.push({
severity: opts.severity || "error",
detail: problem.comment,
category: opts.category || name,
subcategory: opts.subcategory,
sourceLocation: {
path: f.path,
const gs = (await ctx.graphClient.query({
name: "InProcessSdmGoals",
variables: {
registration: [sdm.configuration.name],
},
options: {
...QueryNoCacheOptions,
log: configurationValue("sdm.query.logging", false),
},
})).SdmGoal;
const state = !!options && !!options.state ? options.state : SdmGoalState.canceled;
for (const goal of gs) {
if (goal.ts < end) {
logger.debug(
`Canceling goal '${goal.uniqueName}' of goal set '${goal.goalSetId}' because it timed out after '${formatDuration(timeout)}'`);
let description = `${state === SdmGoalState.canceled ? "Canceled" : "Failed"}: ${goal.name}`;
if (!!goal.descriptions) {
if (state === SdmGoalState.canceled && !!goal.descriptions.canceled) {
description = goal.descriptions.canceled;
} else if (state === SdmGoalState.failure && !!goal.descriptions.failed) {
description = goal.descriptions.failed;
}
}
await updateGoal(
ctx,
goal as any,
{
state,
description,
phase: `${formatDuration(timeout)} timeout`,
export function loadKubeClusterConfig(): k8s.KubeConfig {
const kc = new k8s.KubeConfig();
try {
kc.loadFromCluster();
} catch (e) {
logger.debug("Failed to to load in-cluster config, attempting default");
try {
kc.loadFromDefault();
} catch (ex) {
logger.debug("Failed to to load default config");
}
}
return kc;
}
public async send(msg: any, destinations: Destination | Destination[], options?: MessageOptions): Promise {
logger.debug(`Ignoring send message '${JSON.stringify(msg)}'`);
}
}
export async function reportFailureInterpretation(stepName: string,
interpretation: InterpretedLog | undefined,
fullLog: { url?: string, log: string },
id: RemoteRepoRef,
addressChannels: AddressChannels,
retryButton?: slack.Action): Promise {
if (!interpretation) {
if (fullLog.url) {
logger.debug("No log interpretation. Log available at: " + fullLog.url);
return;
}
logger.debug("No log interpretation, no log URL. Sending full log to Slack");
await addressChannels({
content: fullLog.log,
fileType: "text",
fileName: `${stepName}-failure-${id.sha}.log`,
} as any);
return;
}
await addressChannels({
text: `Failed ${stepName} of ${slack.url(`${id.url}/tree/${id.sha}`, id.sha.substr(0, 7))}`,
attachments: [{
title: interpretation.message || "Failure",
title_link: fullLog.url,
fallback: "relevant bits",
text: interpretation.relevantPart,
color: "#ff5050",
actions: retryButton ? [retryButton] : [],