x-fidelity 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.4.1](https://github.com/zotoio/x-fidelity/compare/v1.4.0...v1.4.1) (2024-07-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **rules:** change default sensitive strings rule ([3e14e24](https://github.com/zotoio/x-fidelity/commit/3e14e248cc8ae95a6a79a7f3d5f75b3db6f9d35f))
|
|
7
|
+
|
|
1
8
|
# [1.4.0](https://github.com/zotoio/x-fidelity/compare/v1.3.0...v1.4.0) (2024-07-14)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -112,7 +112,34 @@ Note that not all models consistently return parseable JSON results, so some exp
|
|
|
112
112
|
|
|
113
113
|
## Configuration
|
|
114
114
|
|
|
115
|
-
The configuration
|
|
115
|
+
The configuration for x-fidelity is based on archetypes, which define the rules, operators, facts, and other settings for a specific type of project. You can find example configuration files in the `src/archetypes` directory of the repository.
|
|
116
|
+
|
|
117
|
+
### Archetype Schema
|
|
118
|
+
|
|
119
|
+
An archetype is defined with the following structure:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
interface ArchetypeConfig {
|
|
123
|
+
rules: string[];
|
|
124
|
+
operators: string[];
|
|
125
|
+
facts: string[];
|
|
126
|
+
config: {
|
|
127
|
+
minimumDependencyVersions: Record<string, string>;
|
|
128
|
+
standardStructure: Record<string, any>;
|
|
129
|
+
blacklistPatterns: string[];
|
|
130
|
+
whitelistPatterns: string[];
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- `rules`: An array of rule names to be applied for this archetype.
|
|
136
|
+
- `operators`: An array of operator names used in the rules.
|
|
137
|
+
- `facts`: An array of fact provider names used to gather information about the codebase.
|
|
138
|
+
- `config`: Additional configuration specific to the archetype:
|
|
139
|
+
- `minimumDependencyVersions`: Minimum required versions for dependencies.
|
|
140
|
+
- `standardStructure`: Expected directory structure for the project.
|
|
141
|
+
- `blacklistPatterns`: Patterns for files/directories to be ignored.
|
|
142
|
+
- `whitelistPatterns`: Patterns for files/directories to be included.
|
|
116
143
|
|
|
117
144
|
### Rule Structure
|
|
118
145
|
|
|
@@ -121,7 +148,6 @@ Each rule is defined in a JSON file with the following structure:
|
|
|
121
148
|
```json
|
|
122
149
|
{
|
|
123
150
|
"name": "ruleName",
|
|
124
|
-
"description": "A brief description of the rule",
|
|
125
151
|
"conditions": {
|
|
126
152
|
"all": [
|
|
127
153
|
{
|
|
@@ -132,7 +158,7 @@ Each rule is defined in a JSON file with the following structure:
|
|
|
132
158
|
]
|
|
133
159
|
},
|
|
134
160
|
"event": {
|
|
135
|
-
"type": "
|
|
161
|
+
"type": "violation",
|
|
136
162
|
"params": {
|
|
137
163
|
"message": "Error message when the rule fails"
|
|
138
164
|
}
|
|
@@ -140,6 +166,92 @@ Each rule is defined in a JSON file with the following structure:
|
|
|
140
166
|
}
|
|
141
167
|
```
|
|
142
168
|
|
|
169
|
+
## Creating New Archetypes
|
|
170
|
+
|
|
171
|
+
To create a new archetype:
|
|
172
|
+
|
|
173
|
+
1. Create a new file in the `src/archetypes` directory, e.g., `myNewArchetype.ts`.
|
|
174
|
+
2. Define the archetype configuration following the `ArchetypeConfig` interface.
|
|
175
|
+
3. Add any necessary rules in the `src/rules` directory.
|
|
176
|
+
4. If needed, create custom operators in the `src/operators` directory.
|
|
177
|
+
5. If needed, create custom fact providers in the `src/facts` directory.
|
|
178
|
+
6. Update the `src/archetypes/index.ts` file to include your new archetype.
|
|
179
|
+
|
|
180
|
+
Example of a new archetype:
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
export const myNewArchetype: ArchetypeConfig = {
|
|
184
|
+
rules: ['myCustomRule', 'standardRule1', 'standardRule2'],
|
|
185
|
+
operators: ['myCustomOperator', 'standardOperator1'],
|
|
186
|
+
facts: ['myCustomFact', 'standardFact1'],
|
|
187
|
+
config: {
|
|
188
|
+
minimumDependencyVersions: {
|
|
189
|
+
'my-framework': '^2.0.0'
|
|
190
|
+
},
|
|
191
|
+
standardStructure: {
|
|
192
|
+
src: {
|
|
193
|
+
components: null,
|
|
194
|
+
utils: null
|
|
195
|
+
},
|
|
196
|
+
tests: null
|
|
197
|
+
},
|
|
198
|
+
blacklistPatterns: ['.*\\/\\..*', '.*\\/(dist|build)(\\/.*|$)'],
|
|
199
|
+
whitelistPatterns: ['.*\\.(ts|tsx|js|jsx)$']
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Extensibility
|
|
205
|
+
|
|
206
|
+
x-fidelity is designed to be highly extensible:
|
|
207
|
+
|
|
208
|
+
1. **Custom Rules**: Create new rules by adding JSON files in the `src/rules` directory.
|
|
209
|
+
2. **Custom Operators**: Implement new operators in the `src/operators` directory and add them to `src/operators/index.ts`.
|
|
210
|
+
3. **Custom Facts**: Create new fact providers in the `src/facts` directory and add them to `src/facts/index.ts`.
|
|
211
|
+
4. **New Archetypes**: As described above, create new archetypes to support different project types or frameworks.
|
|
212
|
+
|
|
213
|
+
## Hosting Config Servers
|
|
214
|
+
|
|
215
|
+
To host a config server for x-fidelity:
|
|
216
|
+
|
|
217
|
+
1. Set up a Node.js server environment (e.g., using Express.js).
|
|
218
|
+
2. Implement endpoints that serve the archetype configurations and rules.
|
|
219
|
+
3. Ensure the server is secure and can handle the expected load.
|
|
220
|
+
4. Use HTTPS for secure communication.
|
|
221
|
+
5. Implement caching mechanisms to improve performance.
|
|
222
|
+
6. Consider using a CDN for global distribution and lower latency.
|
|
223
|
+
|
|
224
|
+
Example server setup (simplified):
|
|
225
|
+
|
|
226
|
+
```javascript
|
|
227
|
+
const express = require('express');
|
|
228
|
+
const app = express();
|
|
229
|
+
|
|
230
|
+
app.get('/archetypes/:archetype', (req, res) => {
|
|
231
|
+
const archetype = req.params.archetype;
|
|
232
|
+
// Fetch and return the archetype configuration
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
app.get('/archetypes/:archetype/rules/:rule', (req, res) => {
|
|
236
|
+
const archetype = req.params.archetype;
|
|
237
|
+
const rule = req.params.rule;
|
|
238
|
+
// Fetch and return the specific rule for the archetype
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
app.listen(8888, () => {
|
|
242
|
+
console.log('Config server running on port 8888');
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Best practices for hosting:
|
|
247
|
+
|
|
248
|
+
- Use environment variables for sensitive information.
|
|
249
|
+
- Implement proper error handling and logging.
|
|
250
|
+
- Set up monitoring and alerting for the server.
|
|
251
|
+
- Regularly update and maintain the server and its dependencies.
|
|
252
|
+
- Implement rate limiting to prevent abuse.
|
|
253
|
+
- Consider using containerization (e.g., Docker) for easy deployment and scaling.
|
|
254
|
+
|
|
143
255
|
## License
|
|
144
256
|
|
|
145
257
|
This project is licensed under the MIT License.
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
"fact": "fileData",
|
|
7
7
|
"path": "$.fileContent",
|
|
8
8
|
"operator": "fileContains",
|
|
9
|
-
"value": "
|
|
9
|
+
"value": "tokenz"
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
"fact": "fileData",
|
|
13
13
|
"path": "$.fileContent",
|
|
14
14
|
"operator": "fileContains",
|
|
15
|
-
"value": "
|
|
15
|
+
"value": "secretx"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"fact": "fileData",
|
package/package.json
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
"fact": "fileData",
|
|
7
7
|
"path": "$.fileContent",
|
|
8
8
|
"operator": "fileContains",
|
|
9
|
-
"value": "
|
|
9
|
+
"value": "tokenz"
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
"fact": "fileData",
|
|
13
13
|
"path": "$.fileContent",
|
|
14
14
|
"operator": "fileContains",
|
|
15
|
-
"value": "
|
|
15
|
+
"value": "secretx"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"fact": "fileData",
|