Skip to content

Commit

Permalink
Merge pull request #1565 from akto-api-security/feature/show_non_sens…
Browse files Browse the repository at this point in the history
…itive_data

show non-sensitive data
  • Loading branch information
notshivansh authored Sep 27, 2024
2 parents 592d96b + 40a4510 commit e44afc5
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ function ApiChanges() {
setShowDetails={setShowDetails}
apiDetail={apiDetail}
headers={tableHeaders}
getStatus={() => { return "warning" }}
/>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import transform from "../transform";
import ApiDependency from "./ApiDependency";
import RunTest from "./RunTest";
import PersistStore from "../../../../main/PersistStore";
import values from "@/util/values";

import { HorizontalDotsMinor, FileMinor } from "@shopify/polaris-icons"

Expand All @@ -30,6 +31,18 @@ function ApiDetails(props) {
const [showMoreActions, setShowMoreActions] = useState(false)
const setSelectedSampleApi = PersistStore(state => state.setSelectedSampleApi)

const statusFunc = getStatus ? getStatus : (x) => {
try {
if (paramList && paramList.length > 0 &&
paramList.filter(x => x?.nonSensitiveDataType).map(x => x.subTypeString).includes(x)) {
return "info"
}
} catch (e) {

}
return "warning"
}

const fetchData = async () => {
if (showDetails) {
setLoading(true)
Expand Down Expand Up @@ -77,8 +90,16 @@ function ApiDetails(props) {
resp.data.params[index].subType = JSON.parse(JSON.stringify(resp.data.params[index].subType))
}
}

})

try {
resp.data.params?.forEach(x => {
if (!values?.skipList.includes(x.subTypeString) && !x?.savedAsSensitive && !x?.sensitive) {
x.nonSensitiveDataType = true
}
})
} catch (e){
}
setParamList(resp.data.params)
})
})
Expand Down Expand Up @@ -190,14 +211,25 @@ function ApiDetails(props) {
method: apiDetail.method,
endpoint: apiDetail.endpoint
}

try {
newData['nonSensitiveTags'] = [...new Set(paramList.filter(x => x?.nonSensitiveDataType).map(x => x.subTypeString))]
} catch (e){
}
try {
newData['sensitiveTags'] = apiDetail?.sensitiveTags && apiDetail?.sensitiveTags.length > 0 ? apiDetail?.sensitiveTags :
[...new Set(paramList.filter(x => x?.savedAsSensitive || x?.sensitive).map(x => x.subTypeString))]
} catch (e){
}

const headingComp = (
<div style={{ display: "flex", justifyContent: "space-between" }} key="heading">
<div style={{ display: "flex", gap: '8px' }}>
<GithubCell
width="32vw"
data={newData}
headers={headers}
getStatus={getStatus}
getStatus={statusFunc}
isBadgeClickable={true}
badgeClicked={badgeClicked}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ function ApiEndpoints(props) {
})
}



function handleRefresh() {
fetchData()
Expand Down Expand Up @@ -860,7 +860,6 @@ function ApiEndpoints(props) {
setShowDetails={setShowDetails}
apiDetail={apiDetail}
headers={transform.getDetailsHeaders()}
getStatus={() => { return "warning" }}
isGptActive={isGptActive}
/>,
]
Expand Down Expand Up @@ -899,7 +898,6 @@ function ApiEndpoints(props) {
setShowDetails={setShowDetails}
apiDetail={apiDetail}
headers={transform.getDetailsHeaders()}
getStatus={() => { return "warning" }}
isGptActive={isGptActive}
/>,
<ApiGroupModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function prepareTableData (data, handleBadgeClick) {
data.forEach((element,index) => {
let paramText = element.param.replaceAll("#", ".").replaceAll(".$", "")
let isSensitive = func.isSubTypeSensitive(element)
let nonSensitiveDataType = element?.nonSensitiveDataType
let comp = [(<HorizontalStack gap={"2"} key={index}>
<Text fontWeight="regular" variant="bodyMd">
{paramText}
Expand All @@ -28,7 +29,13 @@ function prepareTableData (data, handleBadgeClick) {
<Badge status="warning">
{element.subType.name}
</Badge>
</Button> : null
</Button> : (nonSensitiveDataType ?
<Button plain monochrome onClick={() => { handleBadgeClick(element.subType.name, "") }}>
<Badge status="info">
{element.subType.name}
</Badge>
</Button> : null)

}
</HorizontalStack>), <Text variant="bodySm" fontWeight="regular" color="subdued">{func.prepareValuesTooltip(element)}</Text>
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ const apiDetailsHeaders = [
value: "parameterisedEndpoint",
itemOrder: 1,
component: (data) => CopyEndpoint(data)
},
{
text: 'Non-Sensitive Params',
value: 'nonSensitiveTags',
itemOrder: 4,
}
]

Expand Down
4 changes: 3 additions & 1 deletion apps/dashboard/web/polaris_web/web/src/util/values.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@ const ranges = [
}
];

export default { today, yesterday, ranges, yesterdayDayEnd, todayDayEnd };
const skipList = ["GENERIC", "TRUE", "FALSE","INTEGER_32", "INTEGER_64", "NULL", "OTHER", "DICT", "FLOAT"]

export default { today, yesterday, ranges, yesterdayDayEnd, todayDayEnd , skipList};

0 comments on commit e44afc5

Please sign in to comment.