
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
fireschema
Advanced tools
Firestore のスキーマを定義してバリデーションを含むセキュリティルールを自動生成するツール
yarn add fireschema
yarn add -D ts-node
# or
npm i -S fireschema
npm i -D ts-node
schema
として named export する)npx fireschema <スキーマのパス>
Case
IUser
)IPostA
または IPostB
)IPostA
)import {
$adapter,
$allow,
$docLabel,
$functions,
$or,
$schema,
adapter,
createFireschema,
dataSchema,
} from 'fireschema'
type IUser = {
name: string
displayName: string | null
age: number
tags: string[]
timestamp: FTypes.Timestamp
}
type IPostA = {
type: 'a'
text: string
}
type IPostB = {
type: 'b'
texts: string[]
}
const UserSchema = dataSchema<IUser>({
name: 'string',
displayName: 'string | null',
age: 'int',
tags: 'list',
timestamp: 'timestamp',
})
const UserAdapter = adapter<IUser>()({
selectors: (q) => ({
teen: () => q.where('age', '>=', 10).where('age', '<', 20),
}),
})
const PostASchema = dataSchema<IPostA>({
type: 'string',
text: 'string',
})
const PostBSchema = dataSchema<IPostB>({
type: 'string',
texts: 'list',
})
const PostAdapter = adapter<IPostA | IPostB>()({})
// const isAdmin = () => `'isAdmin()'`
// const isUserScope = (arg: string) => `isUserScope(${arg})`
export const schema = createFireschema({
[$functions]: {
// /admins/<uid> が存在するかどうか
['isAdmin()']: `
return exists(/databases/$(database)/documents/admins/$(request.auth.uid));
`,
// アクセスしようとするユーザーの uid が 一致するかどうか
['isUserScope(uid)']: `
return request.auth.uid == uid;
`,
},
/**
* /users/{uid}
* schema: UserSchema
* rule:
* [read]: 誰でも可
* [write]: uid がユーザーと一致する場合のみ
*/
users: {
[$docLabel]: 'uid',
[$schema]: UserSchema,
[$adapter]: UserAdapter,
[$allow]: {
read: true,
write: $or(['isUserScope(uid)']),
},
/**
* /users/{uid}/posts/{postId}
* schema: PostASchema または PostBSchema
* rule:
* [read]: 誰でも可
* [write]: uid がユーザーと一致する場合のみ
*/
posts: {
[$docLabel]: 'postId',
[$schema]: [PostASchema, PostBSchema],
[$adapter]: PostAdapter,
[$allow]: {
read: true,
write: $or(['isUserScope(uid)']),
},
},
/**
* /users/{uid}/privatePosts/{postId}
* schema: PostASchema
* rule:
* [read]: uid がユーザーと一致するか admin のみ
* [write]: uid がユーザーと一致する場合のみ
*/
privatePosts: {
[$docLabel]: 'postId',
[$schema]: PostASchema,
[$adapter]: PostAdapter,
[$allow]: {
read: $or(['isAdmin()', 'isUserScope(uid)']),
write: $or(['isUserScope(uid)']),
},
},
},
})
import firebase, { firestore, initializeApp } from 'firebase' // or firebase-admin
const app: firebase.app.App = initializeApp({
// ...
})
const firestoreApp = app.firestore()
const store: FirestoreController<
typeof firestoreApp,
typeof schema
> = initFirestore(firestore, firestoreApp, schema)
const users = storeAdmin.collection('root', 'users')
const user = users.ref.doc('user')
const posts = storeAdmin.collection(user, 'posts')
const post = posts.ref.doc('post')
const usersGroup = storeAdmin.collectionGroup(['users'])
user.get().then((snap) => snap.data()) // => IUser
FAQs
- **Strong type safety for Firestore** - Automatically provide type information to _nested documents_ without unsafe type assertions, from the simple schema. Also support data decoding. - **Security rules generation** - Generate firestore.rules file inclu
The npm package fireschema receives a total of 34 weekly downloads. As such, fireschema popularity was classified as not popular.
We found that fireschema demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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 researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.