Skip to content

Commit b85f1c4

Browse files
committed
add: scoredetect, security_reporter
1 parent f398a11 commit b85f1c4

File tree

6 files changed

+35
-20
lines changed

6 files changed

+35
-20
lines changed

components/scoredetect/actions/create-timestamp-file/create-timestamp-file.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import scoreDetect from "../../scoredetect.app.mjs";
2-
import { getFileStream } from "@pipedream/platform";
2+
import { getFileStreamAndMetadata } from "@pipedream/platform";
33

44
export default {
55
key: "scoredetect-create-timestamp-file",
@@ -17,10 +17,13 @@ export default {
1717
},
1818
},
1919
async run({ $ }) {
20-
const stream = await getFileStream(this.fileOrUrl);
20+
const {
21+
stream, metadata,
22+
} = await getFileStreamAndMetadata(this.fileOrUrl);
2123
const response = await this.scoreDetect.createCertificate({
2224
$,
2325
file: stream,
26+
metadata,
2427
});
2528

2629
$.export("$summary", "Successfully created certificate");

components/scoredetect/scoredetect.app.mjs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
fileOrUrl: {
99
type: "string",
1010
label: "File Path or URL",
11-
description: "The path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp). Alternatively, you can pass the direct URL to a file.",
11+
description: "The file to upload. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.txt`)",
1212
},
1313
text: {
1414
type: "string",
@@ -33,10 +33,19 @@ export default {
3333
});
3434
},
3535
async createCertificate({
36-
file, ...args
36+
file, metadata, ...args
3737
}) {
3838
const data = new FormData();
39-
data.append("file", file);
39+
if (metadata) {
40+
data.append("file", file, {
41+
contentType: metadata.contentType,
42+
knownLength: metadata.size,
43+
filename: metadata.name,
44+
});
45+
}
46+
else {
47+
data.append("file", file);
48+
}
4049

4150
const headers = data.getHeaders();
4251

components/security_reporter/actions/create-finding/create-finding.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default {
1313
key: "security_reporter-create-finding",
1414
name: "Create Security Finding",
1515
description: "Creates a new security finding. [See the documentation](https://trial3.securityreporter.app/api-documentation)",
16-
version: "0.0.1",
16+
version: "0.1.0",
1717
type: "action",
1818
props: {
1919
securityReporter,
@@ -116,8 +116,8 @@ export default {
116116
},
117117
draftDocumentsFile: {
118118
type: "string[]",
119-
label: "Draft Documents File ",
120-
description: "The path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp).",
119+
label: "Draft Documents File",
120+
description: "One or more files to upload. For each entry, provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.txt`)",
121121
optional: true,
122122
},
123123
resolvers: {

components/security_reporter/actions/update-finding/update-finding.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default {
1414
key: "security_reporter-update-finding",
1515
name: "Update Security Finding",
1616
description: "Updates an existing security finding. [See the documentation](https://trial3.securityreporter.app/api-documentation)",
17-
version: "0.0.1",
17+
version: "0.1.0",
1818
type: "action",
1919
props: {
2020
securityReporter,
@@ -146,8 +146,8 @@ export default {
146146
},
147147
draftDocumentsFile: {
148148
type: "string[]",
149-
label: "Draft Documents File ",
150-
description: "The path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp).",
149+
label: "Draft Documents File",
150+
description: "One or more files to upload. For each entry, provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.txt`)",
151151
optional: true,
152152
},
153153
resolvers: {

components/security_reporter/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/security_reporter",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Security Reporter Components",
55
"main": "security_reporter.app.mjs",
66
"keywords": [
@@ -13,7 +13,7 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^3.0.1",
16+
"@pipedream/platform": "^3.1.0",
1717
"form-data": "^4.0.0"
1818
}
1919
}

components/security_reporter/security_reporter.app.mjs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { axios } from "@pipedream/platform";
22
import FormData from "form-data";
3-
import fs from "fs";
4-
import {
5-
checkTmp,
6-
parseObject,
7-
} from "./common/utils.mjs";
3+
import { getFileStreamAndMetadata } from "@pipedream/platform";
4+
import { parseObject } from "./common/utils.mjs";
85

96
export default {
107
type: "app",
@@ -398,8 +395,14 @@ export default {
398395
const files = parseObject(draftDocumentsFile);
399396
for (const path of files) {
400397
const data = new FormData();
401-
const file = fs.createReadStream(checkTmp(path));
402-
data.append("file", file);
398+
const {
399+
stream, metadata,
400+
} = await getFileStreamAndMetadata(path);
401+
data.append("file", stream, {
402+
contentType: metadata.contentType,
403+
knownLength: metadata.size,
404+
filename: metadata.name,
405+
});
403406
data.append("documentable_type", "Finding");
404407
data.append("section", "description");
405408
const { id } = await this.uploadFile({

0 commit comments

Comments
 (0)