Skip to content

Commit

Permalink
Feature/cldn 1541 (#200)
Browse files Browse the repository at this point in the history
* [CLDN-1541] Added the ability to filter on multiple user ID's and IP's at the same time in the Application Links custom viz

* Temp update to image for deploying to PB-stg

* Reverting change to image

* [CLDN-1541] Added a tooltip to the Alfred icon

* Temp update to base image

* Reverting temporary change to image tag

* Update superset-frontend/src/cccs-viz/plugins/plugin-chart-application-links/src/ApplicationLinks.tsx

Co-authored-by: cccs-rc <[email protected]>

* Update superset-frontend/src/cccs-viz/plugins/plugin-chart-application-links/src/ApplicationLinks.tsx

Co-authored-by: cccs-rc <[email protected]>

* [CLDN-1541] Changed the logic around creating the proper links/URL

* Temp update to img

* Undo temp img change

Co-authored-by: cccs-rc <[email protected]>
  • Loading branch information
2 people authored and GITHUB_USERNAME committed Feb 7, 2023
1 parent a9508ce commit 2866c7f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ export default function ApplicationLinks(props: ApplicationsProps) {
}
}

const link_formatter = () => {
let tempString = '';
if (appVal.length > 0) {
tempString = appVal[0];
for (let i = 1; i < appVal.length; i += 1) {
tempString += `%22%2C%20%22${appVal[i]}`;
}
}
return tempString;
};

useEffect(() => {
fetch(
// eslint-disable-next-line no-restricted-globals
Expand All @@ -36,11 +47,15 @@ export default function ApplicationLinks(props: ApplicationsProps) {

if (appType === 'USER_ID') {
setAlfredURL(
`${response.payload?.url}/?expression=MATCH%20(email%3AEMAIL_ADDRESS)%20WHERE%20email.value%20IN%20%5B%22${appVal}%22%5D%20RETURN%20email.value%2C%20email.maliciousness%2C%20email.uri`,
`${
response.payload?.url
}/?expression=MATCH%20(email%3AEMAIL_ADDRESS)%20WHERE%20email.value%20IN%20%5B%22${link_formatter()}%22%5D%20RETURN%20email.value%2C%20email.maliciousness%2C%20email.uri`,
);
} else if (appType === 'IP') {
setAlfredURL(
`${response.payload?.url}/?expression=MATCH%20(ip%3AIP_ADDRESS)%20WHERE%20ip.value%20IN%20%5B%22${appVal}%22%5D%20RETURN%20ip.value%2C%20ip.maliciousness%2C%20ip.creation_date%2C%20ip.created_by%2C%20ip.uri%2C%20ip.report_uri`,
`${
response.payload?.url
}/?expression=MATCH%20(ip%3AIP_ADDRESS)%20WHERE%20ip.value%20IN%20%5B%22${link_formatter()}%22%5D%20RETURN%20ip.value%2C%20ip.maliciousness%2C%20ip.creation_date%2C%20ip.created_by%2C%20ip.uri%2C%20ip.report_uri`,
);
} else {
setAlfredURL(`${response.payload?.url}`);
Expand All @@ -59,13 +74,14 @@ export default function ApplicationLinks(props: ApplicationsProps) {
return (
<div>
<div style={styles.InlineBlock}>
{appVal === '' && appType === '' ? (
{appVal.length === 0 && appType === '' ? (
<div>
<img
height="17"
width="30"
alt="Alfred"
unselectable="on"
title="Alfred"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAjCAYAAAA5dzKxAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAhdEVYdENyZWF0aW9uIFRpbWUAMjAyMToxMDoyMCAxMDo1NjoxODj1iuIAAAdVSURBVFhH7Vh7TJRXFv/Ni5nhVRRQTHShBevSkq6P1FK3dtWiQHazW7O+TRDsuq6Jf7T9Q7ubzSZtdvuHpmnTFbWgriuJumtX3EajbVFKpUCk1NRHqFbkFVTkrcMM8/z2nMPcKaXozOCYdJv+kuG737n3nnt+59xz7v3QaQT8QKD3P38Q+JHM9xUPnUx2djZ0Op38FixYILKHlqZcACINr9crz7q6Ok2v12sGg0F+RqNRu3DhgvT5fD55RhIPNTI7duwAGR34eTwe7Nq1S/pobXlGFMOcIo8bN25osbGxGm0vLSUlRZs8ebK0ExMTtd7eXv+oyCLikeEIMPbv3w+bzSYR2LJlCzZv3iztnp4eHD58WMaosRGDUIownE6nlp6eLpEwm81aZ2en1tzcLDnDspkzZz6UnHkgMl4yyDPCKJX45eXlnBBi+NKlS0XGWLx4s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bNyICZkpxzkygEPM0llyvVtm3bsHXrVlijo1FbUwNXwhS88d86WGjstEeicbmtG3QYIWtqIhrbekmXCX9btxDdLZex6IUX4CM97IiioqKATgabxtZxnjiGXNheXIFrTbeJTKH0j0ZIOcNgImPlntvtRmZmJlpaWmTxmto6PDP3aVzv7MVrR6phG/LB6xikskuejopGksWA7UULMSXxEZz68CPk5+WK8bNmzUJ9fX0gMiMRLPEVgpZmxXW0LlVyeXs0NTXJe25urhDhfPpJ0gQYNa61bhpFX5qswOuBxagTIjwmL3cJ5s6dK3O5+tXW1goRpVtBEQnm96BkRntJQcmLi4ulzQvx3mdwfrhpu7jJKO7jkapYuDwUKTbWb9jGjRsDRu7cuVOe98K9bFEI6wagoLZCY2MjKisrRZaRkYG8vDxp86ltpfKa+9RjMFjj+GYJOmGgN1vx6+wZw+Xa7+Rly5Zh0qRJ0j527Bhu3rwp50+wKIyFcZNhlJSUSM7w+/r166W8DifwsDGFv3gKv3kyBVMmxGEqVbK1VIaXPfeE9A2f7D7Ex8dj1apVIuOPuQMHDoju0VstJJCScWFgYEBLTk6WG3BMTIzW0dEhcjJCniPB3ym0tfxv30CNvXTpUuCmPX36dM3lcok8XIRNRl3pS0tLOTxiwJo1a0Sm+kZiJImxPrwUoUWLFoku1nn8+HGRjaXvfgibjFp8zpw5gcXPnj0rsnAXZ6g5R44cCTiHLqIiGyvK90NYZNTC1dXVgYXpfAh70bHgcDg0ulGLTso97cqVKyIPR/e4CgCXUFpUkpZLK7eJqL83fJDBsFgsKCgoEJ1cVPbs2SN9/B4ymFEoUB5qa2uThGcPUknV+vr6RP4gULr5Pzj04Sa6+X9td+7cEXmoCDky7D1GWVkZBukzgOZi+fLl8kWp+sYLFeW0tDS5RXD71q1bKC8vl/5Q9Yd8N/t/wLhy5vsJ4H+26s1scE22tgAAAABJRU5ErkJggg=="
/>
<p style={styles.InlineText}>
Expand All @@ -84,21 +100,26 @@ export default function ApplicationLinks(props: ApplicationsProps) {
height="17"
width="30"
alt="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YJOmGgN1vx6+wZw+Xa7+Rly5Zh0qRJ0j527Bhu3rwp50+wKIyFcZNhlJSUSM7w+/r166W8DifwsDGFv3gKv3kyBVMmxGEqVbK1VIaXPfeE9A2f7D7Ex8dj1apVIuOPuQMHDoju0VstJJCScWFgYEBLTk6WG3BMTIzW0dEhcjJCniPB3ym0tfxv30CNvXTpUuCmPX36dM3lcok8XIRNRl3pS0tLOTxiwJo1a0Sm+kZiJImxPrwUoUWLFoku1nn8+HGRjaXvfgibjFp8zpw5gcXPnj0rsnAXZ6g5R44cCTiHLqIiGyvK90NYZNTC1dXVgYXpfAh70bHgcDg0ulGLTso97cqVKyIPR/e4CgCXUFpUkpZLK7eJqL83fJDBsFgsKCgoEJ1cVPbs2SN9/B4ymFEoUB5qa2uThGcPUknV+vr6RP4gULr5Pzj04Sa6+X9td+7cEXmoCDky7D1GWVkZBukzgOZi+fLl8kWp+sYLFeW0tDS5RXD71q1bKC8vl/5Q9Yd8N/t/wLhy5vsJ4H+26s1scE22tgAAAABJRU5ErkJggg=="
/>
</a>
{alfredCount > 0 ? (
<p style={styles.InlineText}>
Alfred has seen this {infoType} {alfredCount} time(s). Search
the{' '}
Alfred has seen {appVal.length > 1 ? 'these' : 'this'}{' '}
{infoType}
{appVal.length > 1 ? "s" : ''} {alfredCount} time
{alfredCount > 1 ? 's' : ''}. Search the{' '}
<a href={alfredURL} target="_blank" rel="noreferrer">
Alfred
</a>{' '}
knowledge base.
</p>
) : (
<p style={styles.InlineText}>
Alfred has not seen this {infoType}. Search the{' '}
Alfred has not seen {appVal.length > 1 ? 'these' : 'this'}{' '}
{infoType}
{appVal.length > 1 ? "s" : ''}. Search the{' '}
<a href={alfredURL} target="_blank" rel="noreferrer">
Alfred
</a>{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ export default function transformProps(chartProps: ChartProps) {
const filter = formData.extraFormData.filters[0];
if (filter.col === 'ip_string') {
appType = 'IP';
appVal = filter.val[0];
appVal = filter.val;
break;
} else if (filter.col === 'user_id') {
appType = 'USER_ID';
appVal = filter.val[0];
appVal = filter.val;
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { QueryFormData, TimeseriesDataRecord } from '@superset-ui/core';
export type ApplicationsProps = QueryFormData & {
data: TimeseriesDataRecord[];
application: string;
appVal: string;
appVal: string[];
appType: string;
};
24 changes: 20 additions & 4 deletions superset/proxy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,22 @@ def get_userid(self, user_id: str, **_kwargs: Any) -> Response:
current logged in user, and will then send a request to Alfred to see
if the passed in user_id is in any reports/incidents
:param user_id: String value representing the user id passed in from the front-end
:param user_id: String value representing the user id(s) passed in from the front-end
:param _kwargs: Array representing any other arguments passed to the function
:returns: Response generated from passing values to the make_alfred_connection function
"""
user_emails = user_id.split(",")
user_email_string = ''

if len(user_emails) > 0:
user_email_string = user_emails[0]
for index in range(1, len(user_emails)):
user_email_string += "%22%2C%20%22" + user_emails[index]

url = (
self.ALFRED_URL
+ "/rest/search/cypher?expression=MATCH%20(email%3AEMAIL_ADDRESS)%20WHERE%20email.value%20IN%20%5B%22"
+ user_id
+ user_email_string
+ "%22%5D%20RETURN%20email.value%2C%20email.maliciousness%2C%20email.uri"
)

Expand All @@ -182,14 +190,22 @@ def get_ipstring(self, ip_string: str, **_kwargs: Any) -> Response:
current logged in user, and will then send a request to Alfred to see
if the passed in ip_string is in any reports/incidents
:param ip_string: String value representing the ip passed in from the front-end
:param ip_string: String value representing the ip(s) passed in from the front-end
:param _kwargs: Array representing any other arguments passed to the function
:returns: Response generated from passing values to the make_alfred_connection function
"""
user_ips = ip_string.split(",")
user_ip_string = ''

if len(user_ips) > 0:
user_ip_string = user_ips[0]
for index in range(1, len(user_ips)):
user_ip_string += "%22%2C%20%22" + user_ips[index]

url = (
self.ALFRED_URL
+ "/rest/search/cypher?expression=MATCH%20(ip%3AIP_ADDRESS)%20WHERE%20ip.value%20IN%20%5B%22"
+ ip_string
+ user_ip_string
+ "%22%5D%20RETURN%20ip.value%2C%20ip.maliciousness%2C%20ip.creation_date%2C%20ip.created_by%2C%20ip.uri%2C%20ip.report_uri"
)

Expand Down

0 comments on commit 2866c7f

Please sign in to comment.