Skip to content

Commit

Permalink
Add MIME checks to uploads avScan service (#2787)
Browse files Browse the repository at this point in the history
* fix uploads tests. use vitest.

* add some mime type checks btwn file and ending

* add mime type check test

* use actual eicar pdf file

* fix clamav test

* adds check for csv and txt

* fix scanFile test

* now we mark infected properly here
  • Loading branch information
mojotalantikite authored Oct 8, 2024
1 parent 6e4f390 commit a19797e
Show file tree
Hide file tree
Showing 38 changed files with 1,094 additions and 525 deletions.
529 changes: 252 additions & 277 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions services/app-api/src/postgres/state/findStateAssignedUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ import type { UserType } from '../../domain-models'
import { NotFoundError } from '../postgresErrors'
import { parseDomainUsersFromPrismaUsers } from '../user/prismaDomainUser'

async function findStateAssignedUsers( client: PrismaTransactionType, stateCode: string): Promise<UserType[] | Error> {
async function findStateAssignedUsers(
client: PrismaTransactionType,
stateCode: string
): Promise<UserType[] | Error> {
const pilotStateCodes = statePrograms.states.map((state) => state.code)
if(!pilotStateCodes.includes(stateCode)) {
if (!pilotStateCodes.includes(stateCode)) {
return new Error(`${stateCode} is not a supported state code`)
}

try {
const state = await client.state.findFirst({
where: {
stateCode
stateCode,
},
include: {
assignedCMSUsers: {
Expand All @@ -34,9 +37,7 @@ async function findStateAssignedUsers( client: PrismaTransactionType, stateCode:
return new NotFoundError(err)
}

const users = parseDomainUsersFromPrismaUsers(
state.assignedCMSUsers
)
const users = parseDomainUsersFromPrismaUsers(state.assignedCMSUsers)

return users
} catch (err) {
Expand All @@ -45,4 +46,4 @@ async function findStateAssignedUsers( client: PrismaTransactionType, stateCode:
}
}

export { findStateAssignedUsers }
export { findStateAssignedUsers }
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type flatRevisions = UpdateInformation & {
export const ChangeHistory = ({
contract,
}: ChangeHistoryProps): React.ReactElement => {
const {logAccordionEvent} = useTealium()
const { logAccordionEvent } = useTealium()
const flattenedRevisions = (): flatRevisions[] => {
const result: flatRevisions[] = []

Expand Down Expand Up @@ -164,7 +164,12 @@ export const ChangeHistory = ({
),
expanded: false,
handleToggle: () => {
logAccordionEvent({event_name: 'accordion_opened', heading: getUpdatedByDisplayName(r.updatedBy) ?? 'unknown', link_type:'link_other'})
logAccordionEvent({
event_name: 'accordion_opened',
heading:
getUpdatedByDisplayName(r.updatedBy) ?? 'unknown',
link_type: 'link_other',
})
},
id: dayjs(r.updatedAt).toISOString(),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export const DataDetailContactField = ({
target="_blank"
variant="external"
rel="noreferrer"
event_name='contact_click'
contact_method='email'
event_name="contact_click"
contact_method="email"
>
{email}
</LinkWithLogging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const FilterAccordion = ({
filterTitle,
children,
}: FilterAccordionPropType) => {
const {logAccordionEvent} = useTealium()
const { logAccordionEvent } = useTealium()
/* multiple FilterSelect components are passed into the parent as children, and here we map
over them to display them inside the accordion */
const childFilters = React.Children.map(children, (child) => {
Expand Down Expand Up @@ -48,11 +48,15 @@ export const FilterAccordion = ({
expanded: false,
id: 'filterAccordionItems',
handleToggle: () => {
logAccordionEvent({event_name: 'accordion_opened', heading: extractText(filterTitle), link_type:'link_other'})
}
logAccordionEvent({
event_name: 'accordion_opened',
heading: extractText(filterTitle),
link_type: 'link_other',
})
},
},
]
return (
<Accordion items={accordionItems} className={styles.filterAccordion} />
<Accordion items={accordionItems} className={styles.filterAccordion} />
)
}
2 changes: 1 addition & 1 deletion services/app-web/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Header = ({
const { currentRoute: route } = useCurrentRoute()

const handleLogout = async () => {
await logout({type: 'DEFAULT'})
await logout({ type: 'DEFAULT' })
// no need to handle errors, logout will handle
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export const SessionTimeoutModal = ({
)

const handleLogoutSession = async () => {
idleTimer.message({action: SESSION_ACTIONS.LOGOUT_SESSION_BY_CHOICE}, true)
idleTimer.message(
{ action: SESSION_ACTIONS.LOGOUT_SESSION_BY_CHOICE },
true
)
}
const handleContinueSession = async () => {
idleTimer.activate()
Expand Down
4 changes: 2 additions & 2 deletions services/app-web/src/components/Modal/UnlockSubmitModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const UnlockSubmitModal = ({
modalRef,
setIsSubmitting,
}: UnlockSubmitModalProps): React.ReactElement | null => {
const { logFormSubmitEvent} = useTealium()
const { logFormSubmitEvent } = useTealium()
const [focusErrorsInModal, setFocusErrorsInModal] = useState(true)
const [modalAlert, setModalAlert] = useState<
GenericApiErrorProps | undefined
Expand Down Expand Up @@ -188,7 +188,7 @@ export const UnlockSubmitModal = ({
heading: modalValues.modalHeading ?? 'unknown',
form_name: modalType.toLowerCase(),
event_name: 'form_field_submit',
link_type: 'link_other'
link_type: 'link_other',
})

switch (modalType) {
Expand Down
7 changes: 1 addition & 6 deletions services/app-web/src/components/TealiumLogging/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ type TealiumDataType = Omit<
type LinkWithLoggingType = TealiumDataType & DefaultLinkProps
const LinkWithLogging = (props: LinkWithLoggingType) => {
const { logInternalLinkEvent } = useTealium()
const {
href,
onClick,
children,
...rest
} = props
const { href, onClick, children, ...rest } = props
return (
<Link
onClick={(e) => {
Expand Down
4 changes: 3 additions & 1 deletion services/app-web/src/pages/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ function App({
})
const tealiumEnv = getTealiumEnv(environmentName)
const newTealiumClient =
tealiumEnv === 'dev' ? devTealiumClient(isLocal) : tealiumClient(tealiumEnv)
tealiumEnv === 'dev'
? devTealiumClient(isLocal)
: tealiumClient(tealiumEnv)

return (
<ErrorBoundary FallbackComponent={ErrorBoundaryRoot}>
Expand Down
6 changes: 3 additions & 3 deletions services/app-web/src/pages/App/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ const CMSUserRoutes = ({
element={<SupportEmailsTable />}
/>
<Route
path={RoutesRecord.EDIT_STATE_ASSIGNMENTS}
element={<EditStateAssign />}
/>
path={RoutesRecord.EDIT_STATE_ASSIGNMENTS}
element={<EditStateAssign />}
/>
</Route>
<Route
path={RoutesRecord.SETTINGS}
Expand Down
Loading

0 comments on commit a19797e

Please sign in to comment.