Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for syncing Assessments from OneTrust to Transcend #376

Open
wants to merge 79 commits into
base: main
Choose a base branch
from

Conversation

abrantesarthur
Copy link
Member

@abrantesarthur abrantesarthur commented Jan 10, 2025

I suggest starting the review from the command's entrypoint cli-sync-ot.ts.

See updated README for instructions of how to test this. Locally, you'd do yarn ts-node ./src/cli-sync-ot.ts. instead of yarn cli-sync-ot.

  • adds ability to sync Assessments from OneTrust to Transcend or to Disk.
  • renames the command cli-pull-ot -> cli-sync-ot.
  • update code to use codecs to validate shape of assessments pulled from OT.

Note that requests to importOneTrustAssessmentForms fail because we need to update the endpoint, not because the cli has bugs.

Related Issues

Security Implications

[none]

System Availability

[none]

Copy link

height bot commented Jan 14, 2025

This pull request has been linked to and will mark 3 tasks as "Pending Deploy" when merged:

  • T-41372 Update cli-pull-ot command to support converting OneTrust assessments to CSV format (unlink task)
  • T-41375 Update cli-pull-ot command to enrich risk data with detailed risk information from OT API (unlink task)
  • T-40818 CLI to support uploading of OT assessments CSV into Transcend (unlink task)

@abrantesarthur abrantesarthur changed the title [WIP]: add support for syncing Assessments from OneTrust to Transcend add support for syncing Assessments from OneTrust to Transcend Jan 14, 2025
Copy link
Member

@anotherminh anotherminh left a comment

Choose a reason for hiding this comment

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

Other than the FIXME i think this is honestly ... pretty good and ready to go

hostname,
oneTrustAuth,
transcendAuth,
transcendUrl,
Copy link
Member

Choose a reason for hiding this comment

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

so transcendAuth + transcendUrl are optional? If they don't pass it in we'll just save to disk?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, with a caveat: the criteria for saving to disk is that --dryRun=true, in which case we the parseCliSyncOtArguments helper also ensures that transcendAuth + transcendUrl were passed in.

Copy link
Member

Choose a reason for hiding this comment

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

Wait i thought dryrun=true would mean don't upload to Transcend

/**
* fetch details about each assessment in series and write to transcend or to disk
* (depending on the dryRun argument) right away to avoid running out of memory
*/
Copy link
Member

Choose a reason for hiding this comment

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

nice

* fetch details about each assessment in series and write to transcend or to disk
* (depending on the dryRun argument) right away to avoid running out of memory
*/
await mapSeries(assessments, async (assessment, index) => {
Copy link
Member

Choose a reason for hiding this comment

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

wish we could do this with some concurrency.. maybe chunks of 5-10 assessments at a time? IDK what their rate limit is but we'd want to stay under it

Copy link
Member Author

Choose a reason for hiding this comment

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

I think OT would allow for it. My main concern was introducing concurrency bugs (e.g., writing to a file is pretty slow and it's possible to mess up the writing order if doing so concurrently).

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps we can do the fetching from OneTrust concurrently but the writing to Disk or Transcend synchronously? I. can try that.

Copy link
Member

Choose a reason for hiding this comment

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

^ yea! that's sort of what i was thinking. Concurrently fire off 5-10 requests but then write it down concurrently

const { risks, ...restQuestion } = question;
const enrichedRisks = (risks ?? []).map((risk) => {
const details = riskDetailsById[risk.riskId];
// FIXME: missing the risk meta data and links to the assessment
Copy link
Member

Choose a reason for hiding this comment

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

did you mean to do this FIXME

Copy link
Member

@michaelfarrell76 michaelfarrell76 left a comment

Choose a reason for hiding this comment

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

this is killer, wow!

* @param param - information about the assessment and amount of entries
* @returns a stringified csv entry ready to be appended to a file
*/
export const oneTrustAssessmentToCsv = ({
Copy link
Member

Choose a reason for hiding this comment

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

nit: would be nice to have some unit tests for these due to complexity but not a big deal

| file | Path to the file to pull the resource into. Its format must match the fileFormat argument. | string | N/A | false |
| fileFormat | The format of the output file. | string | csv | false |
| resource | The resource to pull from OneTrust. For now, only assessments is supported. | string | assessments | false |
| dryRun | Whether to export the resource to a file rather than sync to Transcend. | boolean | false | false |
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth trying to convey that some arguments are conditionally required? E.g. I assume if you have --dryRun then file is required, and if you don't then transcendAuth/transcendUrl are required

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.

4 participants