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

[Snyk] Security upgrade react-scripts from 4.0.3 to 5.0.0 #21

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16 as build
FROM node:16-bookworm as build
# make sure app variable is set and valid
ARG app=""
RUN : "${app:?Missing --build-arg app}"
Expand All @@ -12,7 +12,7 @@ RUN yarn --network-timeout 100000
RUN yarn build:$app
RUN mv ./apps/$app/bundle-$app/ ./bundle/

FROM node:16
FROM node:16-bookworm
RUN npm install --location=global serve
COPY --from=build /tmp/app/bundle/ /var/www/app/
WORKDIR /var/www/app/
Expand Down
3 changes: 2 additions & 1 deletion apps/genetics/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="shortcut icon" href="/favicon.png" />
<link rel="manifest" href="/manifest.json" />

<script src="/matomo/get_logged_in_user.js"></script>
<script src="/matomo/init_matomo.js"></script>
<title>Open Targets Genetics</title>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion apps/genetics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"react-helmet": "^6.0.0",
"react-measure": "^2.1.2",
"react-router-dom": "5.1.2",
"react-scripts": "4.0.3",
"react-scripts": "5.0.0",
"react-scroll": "^1.7.16",
"react-select": "^5.3.2",
"react-sizeme": "^3.0.2",
Expand Down
24 changes: 24 additions & 0 deletions apps/genetics/public/matomo/get_logged_in_user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
Returns a promise of logged-in user id.
This function assumes response header contains 'user' entry.
*/
function getLoggedInUser() {
return new Promise(function(resolve, reject) {
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (this.readyState === this.HEADERS_RECEIVED) {
var user = request.getResponseHeader('user');
if (user != null) {
resolve(user);
} else {
reject();
}
}
};
request.onerror = function() {
reject();
};
request.open('HEAD', document.location, true);
request.send(null);
});
}
40 changes: 40 additions & 0 deletions apps/genetics/public/matomo/init_matomo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var _paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */

(function() {
function registerUserVisit() {
getLoggedInUser()
.then(function(user) {
_paq.push(['setUserId', user]);
})
.finally(function() {
_paq.push(['setCustomUrl', window.location.href]);
_paq.push(['setDocumentTitle', window.document.title]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
});
}
var pushState = history.pushState;
history.pushState = function() {
pushState.apply(history, arguments);
registerUserVisit();
};
registerUserVisit();
})();

(function() {
var u = 'DISABLED';
if (u === 'DISABLED') {
return
}
_paq.push(['setTrackerUrl', u + 'matomo.php']);
_paq.push(['setSiteId', '1']);
var d = document,
g = d.createElement('script'),
s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.async = true;
g.defer = true;
g.src = u + 'matomo.js';
s.parentNode.insertBefore(g, s);
})();
Loading