@@ -1230,6 +1230,201 @@ fn graphql_compass() {
12301230 dbg ! ( scan_result. into_vulns( ) [ 0 ] . description( ) ) ;
12311231}
12321232
1233+ #[ test]
1234+ fn global_secret_vuln ( ) {
1235+ let test_forge_project = MockForgeProject :: files_from_string (
1236+ "// src/index.tsx
1237+ import ForgeUI, { render, Fragment, Macro, Text } from '@forge/ui';
1238+ import api, { route, fetch } from '@forge/api';
1239+ import graphqlGateway from '@atlassian/forge-graphql';
1240+
1241+ const secret = 'test';
1242+
1243+ const App = () => {
1244+ let value = 'value'
1245+
1246+ let h = { headers: { authorization: secret } }
1247+
1248+ fetch('url', h)
1249+ foo();
1250+
1251+ return (
1252+ <Fragment>
1253+ <Text>Hello world!</Text>
1254+ </Fragment>
1255+ );
1256+ };
1257+ export const run = render(<Macro app={<App />} />)
1258+ // manifest.yaml
1259+ modules:
1260+ macro:
1261+ - key: basic-hello-world
1262+ function: main
1263+ title: basic
1264+ handler: nothing
1265+ description: Inserts Hello world!
1266+ function:
1267+ - key: main
1268+ handler: index.run
1269+ app:
1270+ id: ari:cloud:ecosystem::app/07b89c0f-949a-4905-9de9-6c9521035986
1271+ permissions:
1272+ scopes:
1273+ - read:component:compass" ,
1274+ ) ;
1275+
1276+ let scan_result = scan_directory_test ( test_forge_project) ;
1277+ assert ! ( scan_result. contains_secret_vuln( 1 ) ) ;
1278+ assert ! ( scan_result. contains_vulns( 1 ) ) ;
1279+ }
1280+
1281+ #[ test]
1282+ fn global_secret_no_vuln ( ) {
1283+ let test_forge_project = MockForgeProject :: files_from_string (
1284+ "// src/index.tsx
1285+ import ForgeUI, { render, Fragment, Macro, Text } from '@forge/ui';
1286+ import api, { route, fetch } from '@forge/api';
1287+ import graphqlGateway from '@atlassian/forge-graphql';
1288+
1289+ const secret = process.env.SECRET;
1290+
1291+ const App = () => {
1292+ let value = 'value'
1293+
1294+ let h = { headers: { authorization: secret } }
1295+
1296+ fetch('url', h)
1297+ foo();
1298+
1299+ return (
1300+ <Fragment>
1301+ <Text>Hello world!</Text>
1302+ </Fragment>
1303+ );
1304+ };
1305+ export const run = render(<Macro app={<App />} />)
1306+ // manifest.yaml
1307+ modules:
1308+ macro:
1309+ - key: basic-hello-world
1310+ function: main
1311+ title: basic
1312+ handler: nothing
1313+ description: Inserts Hello world!
1314+ function:
1315+ - key: main
1316+ handler: index.run
1317+ app:
1318+ id: ari:cloud:ecosystem::app/07b89c0f-949a-4905-9de9-6c9521035986
1319+ permissions:
1320+ scopes:
1321+ - read:component:compass" ,
1322+ ) ;
1323+
1324+ let scan_result = scan_directory_test ( test_forge_project) ;
1325+ assert ! ( scan_result. contains_vulns( 0 ) ) ;
1326+ }
1327+
1328+ #[ test]
1329+ fn global_secret_vuln_reset ( ) {
1330+ let test_forge_project = MockForgeProject :: files_from_string (
1331+ "// src/index.tsx
1332+ import ForgeUI, { render, Fragment, Macro, Text } from '@forge/ui';
1333+ import api, { route, fetch } from '@forge/api';
1334+ import graphqlGateway from '@atlassian/forge-graphql';
1335+
1336+ const secret = 'test';
1337+
1338+ const App = () => {
1339+ let value = 'value'
1340+
1341+ let h = { headers: { authorization: secret } }
1342+
1343+ let secret = process.ENV.secret;
1344+
1345+ fetch('url', h)
1346+ foo();
1347+
1348+ return (
1349+ <Fragment>
1350+ <Text>Hello world!</Text>
1351+ </Fragment>
1352+ );
1353+ };
1354+ export const run = render(<Macro app={<App />} />)
1355+ // manifest.yaml
1356+ modules:
1357+ macro:
1358+ - key: basic-hello-world
1359+ function: main
1360+ title: basic
1361+ handler: nothing
1362+ description: Inserts Hello world!
1363+ function:
1364+ - key: main
1365+ handler: index.run
1366+ app:
1367+ id: ari:cloud:ecosystem::app/07b89c0f-949a-4905-9de9-6c9521035986
1368+ permissions:
1369+ scopes:
1370+ - read:component:compass" ,
1371+ ) ;
1372+
1373+ let scan_result = scan_directory_test ( test_forge_project) ;
1374+ assert ! ( scan_result. contains_vulns( 0 ) ) ;
1375+ }
1376+
1377+ #[ test]
1378+ fn global_secret_vuln_alternate_file ( ) {
1379+ let test_forge_project = MockForgeProject :: files_from_string (
1380+ "//src/constants.tsx
1381+
1382+ export const secret = 'SECRET'
1383+
1384+ //src/index.tsx
1385+ import ForgeUI, { render, Fragment, Macro, Text } from '@forge/ui';
1386+ import api, { route, fetch } from '@forge/api';
1387+ import { secret } from './constants';
1388+ import graphqlGateway from '@atlassian/forge-graphql';
1389+
1390+ const App = () => {
1391+ let value = 'value'
1392+
1393+ let h = { headers: { authorization: secret } }
1394+
1395+ fetch('url', h)
1396+ foo();
1397+
1398+ return (
1399+ <Fragment>
1400+ <Text>Hello world!</Text>
1401+ </Fragment>
1402+ );
1403+ };
1404+ export const run = render(<Macro app={<App />} />)
1405+ // manifest.yaml
1406+ modules:
1407+ macro:
1408+ - key: basic-hello-world
1409+ function: main
1410+ title: basic
1411+ handler: nothing
1412+ description: Inserts Hello world!
1413+ function:
1414+ - key: main
1415+ handler: index.run
1416+ app:
1417+ id: ari:cloud:ecosystem::app/07b89c0f-949a-4905-9de9-6c9521035986
1418+ permissions:
1419+ scopes:
1420+ - read:component:compass" ,
1421+ ) ;
1422+
1423+ let scan_result = scan_directory_test ( test_forge_project) ;
1424+ assert ! ( scan_result. contains_secret_vuln( 1 ) ) ;
1425+ assert ! ( scan_result. contains_vulns( 1 ) ) ;
1426+ }
1427+
12331428#[ test]
12341429fn graphqlgateway_compass ( ) {
12351430 let test_forge_project = MockForgeProject :: files_from_string (
0 commit comments