snyk / snyk-gradle-plugin

Basic Snyk CLI plugin for Gradle support
Other
25 stars 19 forks source link

feat: store gradle version output meta info #96

Closed sfat closed 5 years ago

sfat commented 5 years ago

What does this PR do?

implementation for https://github.com/snyk/snyk-gradle-plugin/issues/89

sfat commented 5 years ago

linked snyk-gradle-plugin with my local snyk Added this snippet in run-test.ts to check that snyk test -d spits the needed information:

    if (deps.plugin && deps.plugin.meta && deps.plugin.meta.versionBuildInfo) {
      analytics.add('gradleVersion', deps.plugin.meta.versionBuildInfo.gradleVersion);
      const metaBuildVersion = deps.plugin.meta.versionBuildInfo.metaBuildVersion;
      if (metaBuildVersion) {
        analytics.add('metaBuildVersion', metaBuildVersion);
      }
    }

Screenshot with the output from snyk test -d

Screenshot 2019-09-20 at 21 46 48
sfat commented 5 years ago

the job fails because this needs review first: https://github.com/snyk/snyk-cli-interface/pull/21

sfat commented 5 years ago

Changed implementation to saved in MultiProjectResult.meta instead of plugin.meta.

Screenshot 2019-10-21 at 12 17 12

To accomplish the above screenshot, I've modified src/lib/snyk-test/run-test.ts, in assembleLocalPayloads() the following:

    for (const scannedProject of deps.scannedProjects) {
      if (scannedProject && scannedProject.meta && scannedProject.meta.buildInfoVersion) { // from here
        analytics.add('gradleVersion', scannedProject.meta.buildInfoVersion.gradleVersion);
        const metaBuildVersion = scannedProject.meta.buildInfoVersion.metaBuildVersion;
        if (metaBuildVersion) {
          analytics.add('metaBuildVersion', JSON.stringify(metaBuildVersion));
        }
      }