Skip to content

Commit b91d5bf

Browse files
authored
Merge branch 'main' into fix-additional-user-api-leaks
Signed-off-by: Andy Pols <[email protected]>
2 parents e65d42e + 15c68a3 commit b91d5bf

File tree

83 files changed

+2627
-2045
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+2627
-2045
lines changed

.github/workflows/unused-dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
node-version: '22.x'
2222
- name: 'Run depcheck'
2323
run: |
24-
npx depcheck --skip-missing --ignores="tsx,@babel/*,@commitlint/*,eslint,eslint-*,husky,mocha,ts-mocha,ts-node,concurrently,nyc,prettier,typescript,tsconfig-paths,vite-tsconfig-paths"
24+
npx depcheck --skip-missing --ignores="tsx,@babel/*,@commitlint/*,eslint,eslint-*,husky,mocha,ts-mocha,ts-node,concurrently,nyc,prettier,typescript,tsconfig-paths,vite-tsconfig-paths,history,@types/domutils"
2525
echo $?
2626
if [[ $? == 1 ]]; then
2727
echo "Unused dependencies or devDependencies found"

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,5 @@
7979
To create a production bundle, use `npm run build` or `yarn build`.
8080
-->
8181
</body>
82-
<script type="module" src="/src/index.jsx"></script>
82+
<script type="module" src="/src/index.tsx"></script>
8383
</html>

package-lock.json

Lines changed: 96 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "@finos/git-proxy",
3-
"version": "1.18.2",
3+
"version": "1.19.0",
44
"description": "Deploy custom push protections and policies on top of Git.",
55
"scripts": {
66
"cli": "node ./packages/git-proxy-cli/index.js",
7-
"client": "vite --config vite.config.js",
7+
"client": "vite --config vite.config.ts",
88
"clientinstall": "npm install --prefix client",
99
"server": "tsx index.ts",
1010
"start": "concurrently \"npm run server\" \"npm run client\"",
@@ -88,14 +88,17 @@
8888
"@babel/preset-react": "^7.22.5",
8989
"@commitlint/cli": "^19.0.0",
9090
"@commitlint/config-conventional": "^19.0.0",
91+
"@types/domutils": "^1.7.8",
9192
"@types/express": "^5.0.1",
9293
"@types/express-http-proxy": "^1.6.6",
9394
"@types/lodash": "^4.17.15",
9495
"@types/mocha": "^10.0.10",
9596
"@types/node": "^22.13.5",
97+
"@types/react-dom": "^17.0.11",
98+
"@types/react-html-parser": "^2.0.7",
9699
"@types/yargs": "^17.0.33",
97-
"@typescript-eslint/eslint-plugin": "^8.26.1",
98-
"@typescript-eslint/parser": "^8.26.1",
100+
"@typescript-eslint/eslint-plugin": "^8.29.0",
101+
"@typescript-eslint/parser": "^8.29.0",
99102
"@vitejs/plugin-react": "^4.0.2",
100103
"chai": "^4.2.0",
101104
"chai-http": "^4.3.0",

src/ui/views/RepoList/Components/RepoOverview.jsx renamed to src/constants/languageColors.ts

Lines changed: 2 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import React, { useEffect } from 'react';
2-
import { Snackbar, TableCell, TableRow } from '@material-ui/core';
3-
import GridContainer from '../../../components/Grid/GridContainer';
4-
import GridItem from '../../../components/Grid/GridItem';
5-
import { CodeReviewIcon, LawIcon, PeopleIcon } from '@primer/octicons-react';
1+
// src/constants/languageColors.ts
62

7-
const colors = {
3+
export const languageColors: Record<string, string> = {
84
'1C Enterprise': '#814CCC',
95
'2-Dimensional Array': '#38761D',
106
'4D': '#004289',
@@ -563,125 +559,3 @@ const colors = {
563559
ZIL: '#dc75e5',
564560
Zimpl: '#d67711',
565561
};
566-
567-
import axios from 'axios';
568-
import moment from 'moment';
569-
import CodeActionButton from '../../../components/CustomButtons/CodeActionButton';
570-
571-
export default function Repositories(props) {
572-
const [github, setGitHub] = React.useState({});
573-
574-
const [errorMessage, setErrorMessage] = React.useState('');
575-
const [snackbarOpen, setSnackbarOpen] = React.useState(false);
576-
577-
useEffect(() => {
578-
getGitHubRepository();
579-
}, [props.data.project, props.data.name]);
580-
581-
const getGitHubRepository = async () => {
582-
await axios
583-
.get(`https://api.github.com/repos/${props.data.project}/${props.data.name}`)
584-
.then((res) => {
585-
setGitHub(res.data);
586-
})
587-
.catch((error) => {
588-
setErrorMessage(`Error fetching GitHub repository ${props.data.project}/${props.data.name}: ${error}`);
589-
setSnackbarOpen(true);
590-
});
591-
};
592-
593-
const { project: org, name, proxyURL } = props?.data || {};
594-
const cloneURL = `${proxyURL}/${org}/${name}.git`;
595-
596-
return (
597-
<TableRow>
598-
<TableCell>
599-
<div style={{ padding: '15px' }}>
600-
<a href={`/dashboard/repo/${props.data.name}`}>
601-
<span style={{ fontSize: '17px' }}>
602-
{props.data.project}/{props.data.name}
603-
</span>
604-
</a>
605-
{github.parent && (
606-
<span
607-
style={{
608-
fontSize: '11.5px',
609-
display: 'block',
610-
opacity: 0.8,
611-
}}
612-
>
613-
Forked from{' '}
614-
<a
615-
style={{
616-
fontWeight: 'normal',
617-
color: 'inherit',
618-
}}
619-
href={github.parent.html_url}
620-
>
621-
{github.parent.full_name}
622-
</a>
623-
</span>
624-
)}
625-
{github.description && <p style={{ maxWidth: '80%' }}>{github.description}</p>}
626-
<GridContainer>
627-
{github.language && (
628-
<GridItem>
629-
<span
630-
style={{
631-
height: '12px',
632-
width: '12px',
633-
backgroundColor: `${colors[github.language]}`,
634-
borderRadius: '50px',
635-
display: 'inline-block',
636-
marginRight: '5px',
637-
}}
638-
></span>
639-
{github.language}
640-
</GridItem>
641-
)}
642-
{github.license && (
643-
<GridItem>
644-
<LawIcon size='small' />{' '}
645-
<span style={{ marginLeft: '5px' }}>{github.license.spdx_id}</span>
646-
</GridItem>
647-
)}
648-
<GridItem>
649-
<PeopleIcon size='small' />{' '}
650-
<span style={{ marginLeft: '5px' }}>{props.data.users?.canPush?.length || 0}</span>
651-
</GridItem>
652-
<GridItem>
653-
<CodeReviewIcon size='small' />{' '}
654-
<span style={{ marginLeft: '5px' }}>
655-
{props.data.users?.canAuthorise?.length || 0}
656-
</span>
657-
</GridItem>
658-
{(github.created_at || github.updated_at || github.pushed_at) && (
659-
<GridItem>
660-
Last updated{' '}
661-
{moment
662-
.max([
663-
moment(github.created_at),
664-
moment(github.updated_at),
665-
moment(github.pushed_at),
666-
])
667-
.fromNow()}
668-
</GridItem>
669-
)}
670-
</GridContainer>
671-
</div>
672-
</TableCell>
673-
<TableCell align='right'>
674-
<div style={{ padding: '15px' }}>
675-
<CodeActionButton cloneURL={cloneURL} />
676-
</div>
677-
</TableCell>
678-
<Snackbar
679-
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
680-
open={snackbarOpen}
681-
autoHideDuration={6000}
682-
onClose={() => setSnackbarOpen(false)}
683-
message={errorMessage}
684-
/>
685-
</TableRow>
686-
);
687-
}

src/context.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/context.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createContext } from 'react';
2+
import { UserContextType } from './ui/views/RepoDetails/RepoDetails';
3+
4+
export const UserContext = createContext<UserContextType>({
5+
user: {
6+
admin: false,
7+
},
8+
});

src/index.jsx renamed to src/index.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import { createBrowserHistory } from 'history';
43
import { BrowserRouter as Router, Route, Routes, Navigate } from 'react-router-dom';
54
import { AuthProvider } from './ui/auth/AuthProvider';
65

@@ -11,16 +10,14 @@ import './ui/assets/css/material-dashboard-react.css';
1110
import NotAuthorized from './ui/views/Extras/NotAuthorized';
1211
import NotFound from './ui/views/Extras/NotFound';
1312

14-
const hist = createBrowserHistory();
15-
1613
ReactDOM.render(
1714
<AuthProvider>
18-
<Router history={hist}>
15+
<Router>
1916
<Routes>
20-
<Route exact path='/dashboard/*' element={<Dashboard />} />
21-
<Route exact path='/login' element={<Login />} />
22-
<Route exact path='/not-authorized' element={<NotAuthorized />} />
23-
<Route exact path='/' element={<Navigate from='/' to='/dashboard/repo' />} />
17+
<Route path='/dashboard/*' element={<Dashboard />} />
18+
<Route path='/login' element={<Login />} />
19+
<Route path='/not-authorized' element={<NotAuthorized />} />
20+
<Route path='/' element={<Navigate to='/dashboard/repo' />} />
2421
<Route path='*' element={<NotFound />} />
2522
</Routes>
2623
</Router>

src/routes.jsx renamed to src/routes.tsx

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,91 +27,73 @@ import RepoDetails from './ui/views/RepoDetails/RepoDetails';
2727
import RepoList from './ui/views/RepoList/RepoList';
2828

2929
import { RepoIcon } from '@primer/octicons-react';
30-
3130
import { Group, AccountCircle, Dashboard } from '@material-ui/icons';
31+
import { Route } from './types/models';
3232

33-
const dashboardRoutes = [
33+
const dashboardRoutes: Route[] = [
3434
{
3535
path: '/repo',
3636
name: 'Repositories',
3737
icon: RepoIcon,
38-
component: (props) =>
39-
<RouteGuard
40-
component={RepoList}
41-
fullRoutePath={`/dashboard/repo`}
42-
/>,
38+
component: (props) => <RouteGuard component={RepoList} fullRoutePath={`/dashboard/repo`} />,
4339
layout: '/dashboard',
4440
visible: true,
4541
},
4642
{
4743
path: '/repo/:id',
4844
name: 'Repo Details',
4945
icon: Person,
50-
component: (props) =>
51-
<RouteGuard
52-
component={RepoDetails}
53-
fullRoutePath={`/dashboard/repo/:id`}
54-
/>,
46+
component: (props) => (
47+
<RouteGuard component={RepoDetails} fullRoutePath={`/dashboard/repo/:id`} />
48+
),
5549
layout: '/dashboard',
5650
visible: false,
5751
},
5852
{
5953
path: '/push',
6054
name: 'Dashboard',
6155
icon: Dashboard,
62-
component: (props) =>
63-
<RouteGuard
64-
component={OpenPushRequests}
65-
fullRoutePath={`/dashboard/push`}
66-
/>,
56+
component: (props) => (
57+
<RouteGuard component={OpenPushRequests} fullRoutePath={`/dashboard/push`} />
58+
),
6759
layout: '/dashboard',
6860
visible: true,
6961
},
7062
{
7163
path: '/push/:id',
7264
name: 'Open Push Requests',
7365
icon: Person,
74-
component: (props) =>
75-
<RouteGuard
76-
component={PushDetails}
77-
fullRoutePath={`/dashboard/push/:id`}
78-
/>,
66+
component: (props) => (
67+
<RouteGuard component={PushDetails} fullRoutePath={`/dashboard/push/:id`} />
68+
),
7969
layout: '/dashboard',
8070
visible: false,
8171
},
8272
{
8373
path: '/profile',
8474
name: 'My Account',
8575
icon: AccountCircle,
86-
component: (props) =>
87-
<RouteGuard
88-
component={User}
89-
fullRoutePath={`/dashboard/profile`}
90-
/>,
76+
component: (props) => <RouteGuard component={User} fullRoutePath={`/dashboard/profile`} />,
9177
layout: '/dashboard',
9278
visible: true,
9379
},
9480
{
9581
path: '/admin/user',
9682
name: 'Users',
9783
icon: Group,
98-
component: (props) =>
99-
<RouteGuard
100-
component={UserList}
101-
fullRoutePath={`/dashboard/admin/user`}
102-
/>,
84+
component: (props) => (
85+
<RouteGuard component={UserList} fullRoutePath={`/dashboard/admin/user`} />
86+
),
10387
layout: '/dashboard',
10488
visible: true,
10589
},
10690
{
10791
path: '/admin/user/:id',
10892
name: 'User',
10993
icon: Person,
110-
component: (props) =>
111-
<RouteGuard
112-
component={User}
113-
fullRoutePath={`/dashboard/admin/user/:id`}
114-
/>,
94+
component: (props) => (
95+
<RouteGuard component={User} fullRoutePath={`/dashboard/admin/user/:id`} />
96+
),
11597
layout: '/dashboard',
11698
visible: false,
11799
},

src/service/routes/auth.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@ router.post('/gitAccount', async (req, res) => {
136136
return;
137137
}
138138

139+
const reqUser = await db.findUser(req.user.username);
140+
if (username !== reqUser.username && !reqUser.admin) {
141+
res.status(403).send('Error: You must be an admin to update a different account').end();
142+
return;
143+
}
139144
const user = await db.findUser(username);
140-
141145
console.log('Adding gitAccount' + req.body.gitAccount);
142146
user.gitAccount = req.body.gitAccount;
143147
db.updateUser(user);

0 commit comments

Comments
 (0)