Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function hasDependency(on: DependencySpecifier): PredicatePushTest {
return predicatePushTest(
`hasDeclaredDep-${coordinates(on)}`,
async p => {
// Attempt an optimization: Look for it in the fast stuff first
const directDeps = (await findDeclaredDependencies(p)).dependencies;
const direct = dependencyFound(on, directDeps);
if (direct) {
return true;
}
// If we're still going, check transient dependencies
const deps = await findDependenciesFromEffectivePom(p);
return dependencyFound(on, deps);
},
);
}
export function hasDeclaredDependency(on: DependencySpecifier): PredicatePushTest {
return predicatePushTest(
`hasDeclaredDep-${coordinates(on)}`,
async p => {
const deps = (await findDeclaredDependencies(p)).dependencies;
return dependencyFound(on, deps);
},
);
}
export function hasStarter(artifact: string,
group: string = "org.springframework.boot"): PredicatePushTest {
return predicatePushTest(
`has-starter=${group}-${group}`,
hasDeclaredDependency({ artifact, group }).predicate,
);
}
import {
predicatePushTest,
PredicatePushTest,
} from "@atomist/sdm";
import { hasDeclaredDependency } from "../../maven/pushtest/pushTests";
import { SpringBootProjectStructure } from "../generate/SpringBootProjectStructure";
import { SpringBootVersionInspection } from "../inspect/springBootVersionInspection";
import { SpringSecurityVersionInspection } from "../inspect/springSecurityInspection";
/**
* Does this project have a Spring Boot application class?
* This is a robust but expensive test as it needs
* to scan all Java sources
*/
export const HasSpringBootApplicationClass: PredicatePushTest = predicatePushTest(
"Has Spring Boot @Application class",
async p => !!(await SpringBootProjectStructure.inferFromJavaOrKotlinSource(p)));
/**
* Does this project's POM use Spring boot?
* @type {PredicatePushTest}
*/
export const HasSpringBootPom: PredicatePushTest = predicatePushTest(
"Has Spring Boot POM",
async p => {
const pom = await p.getFile("pom.xml");
if (!pom) {
return false;
}
return (await pom.getContent()).includes("spring-boot");
},
* Does this project's POM use Spring Framework 5
* @type {PredicatePushTest}
*/
export const IsSpringBoot2Project: PredicatePushTest = predicatePushTest(
"IsSpringBoot2Project",
async p => {
const versions = await SpringBootVersionInspection(p, undefined);
return versions.versions.filter(v => v.version.startsWith("2.")).length > 0;
},
);
/**
* Does this project's POM use Spring Security 5
* @type {PredicatePushTest}
*/
export const IsSecure: PredicatePushTest = predicatePushTest(
"IsSecureSpringBootApplication",
async p => {
const versions = await SpringSecurityVersionInspection(p, undefined);
return versions.length > 0;
},
);
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
predicatePushTest,
PredicatePushTest,
} from "@atomist/sdm";
/**
* Is this a Gradle project
* @constructor
*/
export const IsGradle: PredicatePushTest = predicatePushTest(
"Is Gradle",
async p => !!(await p.getFile("build.gradle")) || !!(await p.getFile("build.gradle.kts")));
* limitations under the License.
*/
import {
logger,
projectUtils,
} from "@atomist/automation-client";
import {
anyFileChangedWithExtension,
filesChangedSince,
predicatePushTest,
pushTest,
PushTest,
} from "@atomist/sdm";
export const IsJava: PushTest = predicatePushTest(
"Is Java",
async p =>
projectUtils.fileExists(p, "**/*.java", () => true));
const FileToWatch = ["java", "html", "json", "yml", "yaml", "xml", "sh", "kt", "properties"];
/**
* Veto if change to deployment unit doesn't seem important enough to
* build and deploy
*/
export const MaterialChangeToJavaRepo: PushTest = pushTest("Material change to Java repo", async pci => {
const changedFiles = await filesChangedSince(pci.project, pci.push);
if (!changedFiles) {
logger.info("Cannot determine if change is material on %j: can't enumerate changed files", pci.id);
return true;
}
import { SpringSecurityVersionInspection } from "../inspect/springSecurityInspection";
/**
* Does this project have a Spring Boot application class?
* This is a robust but expensive test as it needs
* to scan all Java sources
*/
export const HasSpringBootApplicationClass: PredicatePushTest = predicatePushTest(
"Has Spring Boot @Application class",
async p => !!(await SpringBootProjectStructure.inferFromJavaOrKotlinSource(p)));
/**
* Does this project's POM use Spring boot?
* @type {PredicatePushTest}
*/
export const HasSpringBootPom: PredicatePushTest = predicatePushTest(
"Has Spring Boot POM",
async p => {
const pom = await p.getFile("pom.xml");
if (!pom) {
return false;
}
return (await pom.getContent()).includes("spring-boot");
},
);
/**
* Does this project's POM use Spring Framework (including
* Spring Boot).
* @type {PredicatePushTest}
*/
export const HasSpringPom: PredicatePushTest = predicatePushTest(
"Has Spring Boot POM",
async p => {
const pom = await p.getFile("pom.xml");
if (!pom) {
return false;
}
return (await pom.getContent()).includes("spring-boot");
},
);
/**
* Does this project's POM use Spring Framework (including
* Spring Boot).
* @type {PredicatePushTest}
*/
export const HasSpringPom: PredicatePushTest = predicatePushTest(
"Has Spring POM",
async p => {
const pom = await p.getFile("pom.xml");
if (!pom) {
return false;
}
return (await pom.getContent()).includes("springframework");
},
);
/**
* Does this project directly declare the given Spring Boot starter
* @param {string} artifact
* @param {string} group
* @return {PredicatePushTest}
*/
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
predicatePushTest,
PredicatePushTest,
} from "@atomist/sdm";
/**
* Is this a Riff project?
* @type {PredicatePushTest}
*/
export const IsRiff: PredicatePushTest = predicatePushTest("isRiff",
async p => p.hasFile("riff.toml"));