Skip to content

Conversation

@teodora-sandu
Copy link
Contributor

Adding a fake function that we can call from snyk-ls and gradually add more functionality into. The reason I decided to return SARIF is because both the CLI and snyk-ls read SARIF at the moment and format it into whatever they need to process. SARIF is what we will continue using for Snyk Code scanning as well, so it seemed like a safe first piece of "functionality" to add.

Gradually, we will be moving the bundle creation and analysis code into here.

@teodora-sandu teodora-sandu requested a review from a team as a code owner February 29, 2024 15:56
@teodora-sandu teodora-sandu force-pushed the feat/add-fake-code-scanning-function branch from 51f574c to f422152 Compare February 29, 2024 17:48
Copy link
Contributor

@cmars cmars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really excited to see this starting! Some comments below to consider but nothing blocking.

Some ideas for followups:

  • Could we generate the client (or just these wireformat types) from an OpenAPI spec? I've had good results with https://github.com/deepmap/oapi-codegen. This will help later when we need to iterate on new APIs, or support multiple versions.
  • Could we introduce a linter (https://golangci-lint.run/) and add it to CI? I think it'll really help us maintain code quality in the long term.

Thanks again for this!

pkg/fake/fake.go Outdated
* limitations under the License.
*/

package fake
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this fake go into an internal package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan is to be able to use everything in this package from snyk-ls until Analysis have APIs for us to use. So the reason both this and the SARIF are exposed externally is because of that

"encoding/json"
)

var fakeResponse = `{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider loading this from a testdata fixture file (thinking of https://dave.cheney.net/2016/05/10/test-fixtures-in-go). It may be easier to work with (read, query, format, add more examples) as separate file(s).

@teodora-sandu teodora-sandu force-pushed the feat/add-fake-code-scanning-function branch from 5ffe93b to e61a3ce Compare March 6, 2024 14:36
@teodora-sandu teodora-sandu merged commit 4107274 into main Mar 6, 2024
@teodora-sandu teodora-sandu deleted the feat/add-fake-code-scanning-function branch March 6, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants