Skip to content
Snippets Groups Projects
  1. Dec 07, 2023
    • Jamie Tanna's avatar
      Implement `repositoriesLike` query · 7a755bc0
      Jamie Tanna authored
      
      As part of #151, this requires we introduce the ability to list
      repositories based on `LIKE` SQL syntax, and then performing the
      per-repo lookups.
      
      Right now, we're not wrapping this up with Goroutines to improve
      performance, and we'll optimise it in the future if needed.
      
      We need to make sure we look up whether `totalAdvisories`,
      `totalDependencies` or `totalPolicyViolations` are found in the query
      and then generate the total values as needed, as we cannot wire in the
      resolver (via GQLGen) to wait until the `repositories` field has
      executed.
      
      Co-authored-by: default avatarKeith Lyall <keith.lyall@deliveroo.co.uk>
      7a755bc0
    • Jamie Tanna's avatar
      Implement `repository` query · 245d7a63
      Jamie Tanna authored
      
      This is the first GraphQL query from #151 that provides some more
      significant querying of data, and so requires we wire in a new sqlc
      querier.
      
      This introduces queries that are largely taken from other places, to
      retrieve the core data required by the query.
      
      We can make sure to create lighter-weight queries for `Count`ing data,
      as well as provide a helper method to convert DB types to GraphQL types.
      
      To make sure that we can reference values that are having pointers
      pointed to them, we need to make sure we handle loopvars correctly.
      
      Co-authored-by: default avatarKeith Lyall <keith.lyall@deliveroo.co.uk>
      245d7a63
    • Jamie Tanna's avatar
      Implement `dependentOn` query · e882861f
      Jamie Tanna authored
      
      As part of the implementation of a good first GraphQL API, we can use
      the code from the `dependenton` report to produce the same data via
      GraphQL.
      
      As part of #151.
      
      Similar to the underlying code that performs the reporting, we need to
      add some complex conditionals to perform the right query.
      
      To make sure that we can reference values that are having pointers
      pointed to them, we need to make sure we handle loopvars correctly.
      
      Co-authored-by: default avatarKeith Lyall <keith.lyall@deliveroo.co.uk>
      e882861f
    • Jamie Tanna's avatar
      Add core GraphQL schema types · 97264160
      Jamie Tanna authored
      
      As a design-first approach to considering how we will interact with
      objects in the database using GraphQL as part of #151, we can introduce
      the relevant types and enums.
      
      Co-authored-by: default avatarKeith Lyall <keith.lyall@deliveroo.co.uk>
      97264160
    • Jamie Tanna's avatar
      Add `dmd-graph` to `gendoc` · 5f2e6472
      Jamie Tanna authored
      
      So we can get CLI documentation built into the docs site, as well as
      embed the GraphQL schema into the docs.
      
      This requires renaming the existing schema files/code to make it clearer
      that they were for the database schema.
      
      As part of #151.
      
      Co-authored-by: default avatarKeith Lyall <keith.lyall@deliveroo.co.uk>
      5f2e6472
    • Jamie Tanna's avatar
      Bootstrap GraphQL endpoint · 74f1b054
      Jamie Tanna authored
      
      As a step towards #151, we can introduce the start of our GraphQL API.
      
      We can start by adding support for DMD's inbuilt metadata table, which
      right now has just the version of the CLI that was used to bootstrap the
      database.
      
      This introduces a separate CLI, `dmd-graph` that can be used to serve
      the GraphQL API, as well as wiring it into the `dmd-web` CLI.
      
      Co-authored-by: default avatarKeith Lyall <keith.lyall@deliveroo.co.uk>
      
      Closes #320.
      74f1b054
  2. Dec 06, 2023
  3. Dec 01, 2023
    • Jamie Tanna's avatar
      Merge branch 'feature/dependent-on' into 'main' · 06933141
      Jamie Tanna authored
      Add `dependenton` report
      
      See merge request !167
      06933141
    • Jamie Tanna's avatar
      Add recording for `reportDependenton` · 6f36e7a9
      Jamie Tanna authored
      6f36e7a9
    • Jamie Tanna's avatar
      Add demo for `report dependenton` · 7abcbd76
      Jamie Tanna authored
      7abcbd76
    • Jamie Tanna's avatar
      Add a `dependenton` report · 400b1393
      Jamie Tanna authored
      As a step towards a required query for GraphQL implementation in #151 as
      well as being a useful check anyway, we can introduce a common report
      for listing the usage of a given package, and optionally at a specific
      version.
      
      This implements this as both a CLI and web-driven report. To make it
      easier to use on the web, we can introduce a form to make it easier to
      set the values.
      
      There's a little bit of awkwardness with trying to query `version` and
      `current_version` as part of the same query as not being present, where
      we end up with an empty set of results. For now we can split this into a
      separate query, and follow-up in #324.
      
      This also proves a new model for performing `union`'d queries for
      reports, rather than implementing an interface in each datasource.
      400b1393
  4. Nov 30, 2023
  5. Nov 29, 2023
    • Jamie Tanna's avatar
      Merge branch 'feature/policy-warn' into 'main' · a3120545
      Jamie Tanna authored
      Allow `WARN` level for Policy Violations
      
      Closes #277
      
      See merge request !165
    • Jamie Tanna's avatar
      Update `generatePolicyViolations` demo · 3476497d
      Jamie Tanna authored
      3476497d
    • Jamie Tanna's avatar
      Improve "starting point" for OPA policies · e5605f42
      Jamie Tanna authored
      e5605f42
    • Jamie Tanna's avatar
      Document `warn` for policies · d3089583
      Jamie Tanna authored
      As part of #277.
      d3089583
    • Jamie Tanna's avatar
      Add ability to `warn` in policies · 8ec66df7
      Jamie Tanna authored
      As part of #277, we want to introduce the ability to `warn` in policies,
      as well as `deny`.
      
      This requires we introduce the new level, and make it possible to
      retrieve the `warn` rule out of policies.
      
      We can also refactor the key logic for evaluating policies' evaluation
      results into a helper method, simplifying the work that needs to be done
      and making it clearer in what cases something happens.
      
      Closes #277.
      8ec66df7
    • Jamie Tanna's avatar
      Improve error messages after refactoring policy interface · e2cff948
      Jamie Tanna authored
      As part of 1ecad150, these error
      messages were missed.
      e2cff948
    • Jamie Tanna's avatar
      Introduce the `level` concept for policies · 53184723
      Jamie Tanna authored
      As part of #277, we want to introduce the ability to `warn` in policies,
      as well as `deny`.
      
      This is a good prefactor, as it's a rather sizeable change, and requires
      we:
      
      - wire in the level to queries
      - require that it's a single value, `ERROR`
      - require that it is included in making a violation unique
      53184723
    • Jamie Tanna's avatar
      More safely reference `deny` · e5c311ff
      Jamie Tanna authored
      In the case that `deny` is not specified, we'll receive:
      
          Error: failed to process any results for these policies. Check that
          you're returning the right variables
      
      This isn't super helpful, especially when we can more cautiously look up
      the value using `object.get`.
      e5c311ff
    • Jamie Tanna's avatar
      Merge branch 'chore/fs' into 'main' · 26574a18
      Jamie Tanna authored
      Remove workaround for regal's missing `fs.FS` support
      
      See merge request !164
    • Jamie Tanna's avatar
      Remove workaround for regal's missing `fs.FS` support · 8cdb3493
      Jamie Tanna authored
      Now that upstream have released a fix for
      https://github.com/StyraInc/regal/issues/492, we can pull this version
      and simplify some of our code for packaging custom linting rules.
      8cdb3493
    • Jamie Tanna's avatar
      Merge branch 'feature/external-licenses' into 'main' · df244873
      Jamie Tanna authored
      Introduce `external_licenses` for prioritised license lookups + consume licenses from SBOMs
      
      Closes #223
      
      See merge request !162
      df244873
    • Jamie Tanna's avatar
      Consume licensing data from SBOMs, if present · a97561c4
      Jamie Tanna authored
      As part of #223, we want to consume licensing information from SBOMs, if
      found. We've now introduced the `external_licenses` table, which will
      house this data, we need to consume it.
      
      We can update each SBOM parser and also pull out licensing information,
      if present. With this data, we can then insert it in bulk into the
      `external_licenses` table.
      
      This requires we introduce a new `License` domain model, which matches
      the schema for `external_licenses` and does _not_ match
      `depsdev_licenses` due to us not storing a `package_manager`.
      
      Although not many SBOMs - including those from Dependabot - include any
      licensing information, we can at least wire it in, so as and when we
      have the data made available, we can report on it.
      
      Closes #223.
      a97561c4
    • Jamie Tanna's avatar
      Make `flatten` generic · 7c15ce8e
      Jamie Tanna authored
      As we're going to need it for more than that, we can rewrite it as a
      generic function.
      7c15ce8e
    • Jamie Tanna's avatar
      Prefer `external_licenses` over `depsdev_licenses` · 1a994e01
      Jamie Tanna authored
      In queries to report licensing data, we should prioritise the data
      inserted into `external_licenses`, whether it's parsed by DMD, or has
      provided by the user, as it is assumed that `external_licenses` is more
      reliable.
      
      We need to handle the cases where one or both tables have the data,
      preferring `external_licenses`, as well as avoid returning any data when
      both tables are absent.
      
      This also amends how we retrieve data for policy evaluations, where we
      need to make sure we add a per-dependency `group by`s as we're now doing
      a `group_concat`, and otherwise we'll get invalid results. We want to
      make sure the lack of licenses does not cause any issues with lookups,
      as a dependency is still valid if no licensing data is made available.
      1a994e01
    • Jamie Tanna's avatar
      Introduce the `external_licenses` table · 985b7b21
      Jamie Tanna authored
      As a step towards #223, we can introduce a new table,
      `external_licenses`, which provides the ability to store licensing
      information for dependencies, without relying on DMD's means for
      determining license data.
      
      As part of #223, this will be retrieved from SBOMs, but this also makes
      it possible to sideload the data from other sources, such as more
      consistent or reliable means (taking care to note #251!).
      
      As we're adding a new table, we need to set up the boilerplate,
      including the `repositories.Repository` interface.
      
      Note that this is slightly different to `depsdev_licenses`, as this now
      includes a `package_manager`.
      
      As these values may be inserted manually, we should make sure that
      validation is enforced on the table.
      985b7b21
    • Jamie Tanna's avatar
      Merge branch 'defect/cyclone-sbom-name' into 'main' · f5cf5d2f
      Jamie Tanna authored
      Fix: Correctly construct package names from CycloneDX SBOMs
      
      See merge request !163
      f5cf5d2f
    • Jamie Tanna's avatar
      Fix: Correctly construct package names from CycloneDX SBOMs · 0a7e024e
      Jamie Tanna authored
      An oversight when collecting package names from CycloneDX SBOMs was
      Maven coordinates appear in the format:
      
            "group": "com.fasterxml.jackson.core",
            "name": "jackson-annotations",
      
      And as we only retrieved the `name`, we would be missing `groupId`s.
      0a7e024e
  6. Nov 28, 2023
  7. Nov 27, 2023
Loading