Skip to content

Commit 251b861

Browse files
authored
Merge pull request #10 from e6-qwiet/MarchRebase
March rebase
2 parents d7c1e52 + 71894c8 commit 251b861

File tree

2 files changed

+36
-39
lines changed

2 files changed

+36
-39
lines changed

.github/workflows/qwiet-prezero-workflow.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,26 @@ jobs:
4646
SHIFTLEFT_GRPC_TELEMETRY_HOST: telemetry.shiftleft.io:443
4747
SHIFTLEFT_GRPC_API_HOST: api.shiftleft.io:443
4848

49-
- name: Download export.py and requirements.txt
50-
run: |
51-
curl -O https://raw.githubusercontent.com/ShiftLeftSecurity/field-integrations/master/shiftleft-utils/export.py
52-
curl -O https://raw.githubusercontent.com/ShiftLeftSecurity/field-integrations/master/shiftleft-utils/config.py
53-
curl -O https://raw.githubusercontent.com/ShiftLeftSecurity/field-integrations/master/shiftleft-utils/common.py
54-
curl -O https://raw.githubusercontent.com/ShiftLeftSecurity/field-integrations/master/shiftleft-utils/requirements.txt
49+
# - name: Download export.py and requirements.txt
50+
# run: |
51+
# curl -O https://raw.githubusercontent.com/ShiftLeftSecurity/field-integrations/master/shiftleft-utils/export.py
52+
# curl -O https://raw.githubusercontent.com/ShiftLeftSecurity/field-integrations/master/shiftleft-utils/config.py
53+
# curl -O https://raw.githubusercontent.com/ShiftLeftSecurity/field-integrations/master/shiftleft-utils/common.py
54+
# curl -O https://raw.githubusercontent.com/ShiftLeftSecurity/field-integrations/master/shiftleft-utils/requirements.txt
5555

56-
- name: Install Python dependencies
57-
run: |
58-
python3 -m pip install --upgrade pip
59-
python3 -m pip install -r requirements.txt
56+
# - name: Install Python dependencies
57+
# run: |
58+
# python3 -m pip install --upgrade pip
59+
# python3 -m pip install -r requirements.txt
6060

61-
- name: Run export.py and generate SARIF report
62-
run: |
63-
APP_NAME=${{ github.event.repository.name }}
64-
python3 export.py -f sarif -a $APP_NAME
65-
env:
66-
SHIFTLEFT_ACCESS_TOKEN: ${{ secrets.SHIFTLEFT_ACCESS_TOKEN }}
61+
# - name: Run export.py and generate SARIF report
62+
# run: |
63+
# APP_NAME=${{ github.event.repository.name }}
64+
# python3 export.py -f sarif -a $APP_NAME
65+
# env:
66+
# SHIFTLEFT_ACCESS_TOKEN: ${{ secrets.SHIFTLEFT_ACCESS_TOKEN }}
6767

68-
- name: Upload SARIF file to GitHub Security Tab
69-
uses: github/codeql-action/upload-sarif@v3
70-
with:
71-
sarif_file: ./ngsast-report-${{ github.event.repository.name }}-github.sarif # Correct dynamic path for SARIF output
68+
# - name: Upload SARIF file to GitHub Security Tab
69+
# uses: github/codeql-action/upload-sarif@v3
70+
# with:
71+
# sarif_file: ./ngsast-report-${{ github.event.repository.name }}-github.sarif # Correct dynamic path for SARIF output

src/main/java/io/shiftleft/controller/CustomerController.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
package io.shiftleft.controller;
23

34
import io.shiftleft.model.Account;
@@ -216,55 +217,52 @@ public void loadSettings(HttpServletResponse httpResponse, WebRequest request) t
216217
* @param request
217218
* @throws Exception
218219
*/
219-
@RequestMapping(value = "/saveSettings", method = RequestMethod.GET)
220-
public void saveSettings(HttpServletResponse httpResponse, WebRequest request) throws Exception {
220+
@RequestMapping(value = "/saveSettings", method = RequestMethod.GET)
221+
public void saveSettings(HttpServletResponse httpResponse, WebRequest request) throws Exception {
221222
// "Settings" will be stored in a cookie
222223
// schema: base64(filename,value1,value2...), md5sum(base64(filename,value1,value2...))
223224

224225
if (!checkCookie(request)){
225-
httpResponse.getOutputStream().println("Error");
226-
throw new Exception("cookie is incorrect");
226+
httpResponse.getOutputStream().println("Error");
227+
throw new Exception("cookie is incorrect");
227228
}
228229

229230
String settingsCookie = request.getHeader("Cookie");
230231
String[] cookie = settingsCookie.split(",");
231-
if(cookie.length<2) {
232-
httpResponse.getOutputStream().println("Malformed cookie");
233-
throw new Exception("cookie is incorrect");
232+
if(cookie.length<2) {
233+
httpResponse.getOutputStream().println("Malformed cookie");
234+
throw new Exception("cookie is incorrect");
234235
}
235236

236237
String base64txt = cookie[0].replace("settings=","");
237238

238239
// Check md5sum
239240
String cookieMD5sum = cookie[1];
240241
String calcMD5Sum = DigestUtils.md5Hex(base64txt);
241-
if(!cookieMD5sum.equals(calcMD5Sum))
242+
if(!cookieMD5sum.equals(calcMD5Sum))
242243
{
243-
httpResponse.getOutputStream().println("Wrong md5");
244-
throw new Exception("Invalid MD5");
244+
httpResponse.getOutputStream().println("Wrong md5");
245+
throw new Exception("Invalid MD5");
245246
}
246247

247248
// Now we can store on filesystem
248249
String[] settings = new String(Base64.getDecoder().decode(base64txt)).split(",");
249-
// storage will have ClassPathResource as basepath
250+
// storage will have ClassPathResource as basepath
250251
ClassPathResource cpr = new ClassPathResource("./static/");
251-
// Sanitize filename to prevent directory traversal
252-
String filename = FilenameUtils.getName(settings[0]);
253-
File file = new File(cpr.getPath() + filename);
252+
File file = new File(cpr.getPath()+settings[0]);
254253
if(!file.exists()) {
255-
file.getParentFile().mkdirs();
254+
file.getParentFile().mkdirs();
256255
}
257256

258257
FileOutputStream fos = new FileOutputStream(file, true);
259258
// First entry is the filename -> remove it
260259
String[] settingsArr = Arrays.copyOfRange(settings, 1, settings.length);
261-
// on setting at a line
260+
// on setting at a linez
262261
fos.write(String.join("\n",settingsArr).getBytes());
263262
fos.write(("\n"+cookie[cookie.length-1]).getBytes());
264263
fos.close();
265264
httpResponse.getOutputStream().println("Settings Saved");
266-
}
267-
265+
}
268266

269267
/**
270268
* Debug test for saving and reading a customer
@@ -391,4 +389,3 @@ public void removeCustomer(@PathVariable("customerId") Long customerId, HttpServ
391389
}
392390

393391
}
394-

0 commit comments

Comments
 (0)