import {
ColumnLayout,
Container,
Grid,
Header,
SpaceBetween
} from '@cloudscape-design/components';
import Box from '@cloudscape-design/components/box';
import Link from '@cloudscape-design/components/link';
import { ReactWidget } from '@jupyterlab/apputils';
import { Button } from '@jupyterlab/ui-components';
import React from 'react';
import { ReactMarkdown } from 'react-markdown/lib/react-markdown';
import { codeGuruIcon } from '../constants/icons';
import { codeGuruSecurityScanAccessPolicy } from '../constants/policy';
import { isLightThemeActive } from '../utils';
export class AboutCodeGuru extends ReactWidget {
render(): JSX.Element {
const steps = [
{
header: 'Step 1: Provide necessary permissions',
description: `Go to the [AWS IAM Console](https://us-east-1.console.aws.amazon.com/iamv2/home#/home) to update the permissions policy for each role or user that will use this extension. Use an AWS managed policy or create a policy with the following permissions:
\`\`\`
${codeGuruSecurityScanAccessPolicy}
\`\`\`
`
},
{
header: 'Step 2: Configure credentials',
headerDescription:
'This step is only required for JupyterLab users. SageMaker Studio users can skip this step.',
description: `Refresh your AWS credentials using the AWS CLI. Run the following command to update your AWS configuration:
\`\`\`
aws configure
\`\`\`
`
}
];
return (
Amazon CodeGuru extensionAboutComplete CodeGuru extension installation
Once you install this extension, you must complete these steps
to begin scanning your code.
{steps.map(step => (
{step.header}
}
fitHeight={true}
>
))}
Using the extension
After you install the extension, you can begin using the code
scanning feature. You can run a scan by choosing any code cell in
your file and then choosing the CodeGuru icon{' '}
in the top task
bar. Once a scan is complete, you see findings underlined in your
code. To view details about the findings, you can open the context
(right-click) menu for any cell and choose Show diagnostics panel.
You can also hold your cursor over the underlined code to see a
popover with a summary. For more information on using the
extension, see{' '}
Getting started with the Amazon CodeGuru extension
.
);
}
}
interface IMarkdown {
content: string;
}
export function Markdown({ content }: IMarkdown): JSX.Element {
return (
(
{children}
),
code: ({ children }) => (
{children}
)
}}
>
{content}
);
}
function copyToClipboard(text: string | undefined) {
return navigator.clipboard.writeText(text as string);
}