Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
admin_lsac
Advanced tools
For configuring your own admin panel, follow the next instructions.
npm install admin_lsac
This command will download and install the specified package and its dependencies into your project's node_modules directory, making it available for use in your project.
import { ChakraProvider } from '@chakra-ui/react'
import { pageToUrl } from 'admin_lsac'
import { AdminPage } from 'admin_lsac'
You can import these in App.js / App.ts or wherever your routes to the pages are located.
import { PageSchema } from 'admin_lsac'
If your project is TypeScript-based, you need to use the line above as well.
Import the component from above where you want to write your schemas! (See below for details about schemas)
{your_array.map((page, index) => (
<Route
key={index}
path={`${your_url_to_admin_panel}/${pageToUrl(page)}`}
element={
<AdminPage
pages={your_array}
selectedPage={page} // 'page' param from above
basePath={your_url_to_admin_panel}
apiURL={your_url_to_backend} // optional, for websockets
/>
}
/>
))}
{your_array[0] ? ( // recommended default route when accessing admin panel
<Route
path={`${your_url_to_admin_panel}/*`}
element={
<AdminPage
pages={your_array}
selectedPage={your_array[0]}
basePath={your_url_to_admin_panel}
apiURL={your_url_to_backend} // optional, for websockets
/>
}
/>
) : null}
You will need to create an array of schemas for your own admin panel.
export interface PageSchema {
name: string;
actions: Action[];
rowActions: RowAction[];
getRequest: () => Promise<any[]>;
tableFields: TableField[];
}
export interface TableField {
name: string;
access: (obj: any) => string | number | React.ReactElement;
}
export interface SimpleField {
name: string;
label: string;
type: "string" | "number" | "file";
validationSchema: any;
}
export interface Option {
value: string | number | boolean;
display: string;
}
export interface DropdownField {
name: string;
label: string;
type: "dropdown";
options?: Option[] | undefined;
getOptions: () => Promise<Option[]>;
}
export interface ObjectField {
name: string;
label: string;
type: "object";
fields: FormField[];
}
export interface ArrayField {
name: string;
label: string;
type: "array";
element: Exclude<FormField, ArrayField>;
}
export type FormField = SimpleField | DropdownField | ObjectField | ArrayField;
export interface Action {
name: string;
fields?: FormField[];
onSubmit: (obj1: any, obj2?: any) => Promise<any>;
}
export interface RowAction {
name: string;
fields?: FormField[];
initialise?: (obj: any) => any;
onSubmit: (obj1: any, obj2?: any) => Promise<any>;
}
A page schema is based on these interfaces, and it describes how one table of your admin panel would need to be structured to accomplish what the user needs to do regarding an entity. (i.e. users, teams, companies, quizzes)
The most important interface is PageSchema
, as it is at the top of the relations between all these interfaces.
What do the fields of PageSchema
refer to?
The operations for the rowActions and actions will generally have a form to complete before executing it. There are 4 types of inputs for the form part:
const domain = "http://localhost:3001"; // dev mode
// helper function
const getAuth = () => {
// return a token or whatever :)
};
const companies: PageSchema = {
name: "Companies",
getRequest: async () => { // retrieve all entries from the database
const res = await axios.get(domain + "/something", {
headers: getAuth(),
});
return res.data;
},
tableFields: [ // the columns displayed on the page
{
name: "Company ID", // the ID must be displayed (and as first column),
// if you would like to use rowActions ⚠️
access: (obj: any) => obj.id, // obj.field_name
},
{
name: "Name",
access: (obj: any) => obj.name,
},
{
name: "Logo",
access: (obj: any) => // you can have even more complex functions
obj.logoUrl
? React.createElement("img", {
src: obj.logoUrl,
alt: "ERROR",
style: { width: "100px" },
})
: "No Image Available",
},
],
actions: [
{
name: "Create New Quiz",
fields: [
{
name: "name",
label: "Quiz Name",
type: "string", // for every FormField, type must be specified
validationSchema: Yup.string().required(), // you can also require 'boolean' values with Yup
},
{
name: "questions",
label: "Questions",
type: "array",
element: {
name: "",
label: "",
type: "object",
fields: [
{
name: "text",
label: "Question Text",
type: "string",
validationSchema: Yup.string().required(),
},
{
name: "type",
label: "Question Type",
type: "dropdown",
getOptions: async () => [
{
value: "OPEN",
display: "Open",
},
{
value: "SINGLE",
display: "Single",
},
{
value: "MULTIPLE",
display: "Multiple",
},
],
},
],
},
},
],
onSubmit: async (formValues: any) => { // onSubmit function can also be complex
// for actions, onSubmit will always have one param (formValues - you can change the name though)
// process formVaues as you wish
// Nevertheless, submitting the actual data is the most important thing
const result = await axios.post(domain + "/something", formValues, {
headers: getAuth(),
});
return result.data;
}
},
],
rowActions: [
{
name: "Delete Event - Variant 1", // without form
onSubmit: async (eventId: number) => { // onSubmit has only param, the row's ID
const res = await axios.delete(
domain + "/something/" + eventId
);
return res.data;
},
},
{
name: "Delete Event - Variant 2", // with form
fields: [
{
name: "input",
label: "Mock Field",
type: "string",
validationSchema: "",
},
],
onSubmit: async (formValues: any, eventId: number) => { // onSubmit has two params
// the first param - formValues, while the second is the row's ID
const res = await axios.delete(
domain + "/something/" + eventId
);
return res.data;
},
},
],
}
Please note that the schema above is not related to any entity, and the fields of PageSchema do not necessarily have any relation between them. These are just random examples to teach you how to create your own schemas.
const your_array = [
{
// schema 1
},
{
// schema 2
},
...
];
const your_array: PageSchema[] = [
{
// schema 1
},
{
// schema 2
},
...
];
For real-time changes, this NPM module uses socket.io-client library to implement WebSockets. So, on the server-side, you will have to use socket.io library, and provide an apiURL
as shown above.
In order for it to work, emit an event 'updateData' from the server for every route associated with an action/rowAction. You can also send a message that the client will receive (the message will be shown in the web console).
Due to some corrupt dependencies, you will need a Node version >= 20.5.0 to use this NPM package (it may work in some cases, but we still recommend updating Node to a newer version).
For every entity you describe through a page schema, getRequest and onSubmit functions use routes created for the entity. getRequest
function makes a GET request, while onSumbit
function generally makes a POST, PATCH or DELETE request.
For more details, especially about page schemas, contact the owner. :)
FAQs
Generic Admin Panel created for storing events' data
We found that admin_lsac demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.