Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp

Issue 1739613002: DevTools: validate protocol input parameters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselined a test. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" 5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
6 6
7 #include "platform/JSONValues.h" 7 #include "platform/JSONValues.h"
8 #include "platform/v8_inspector/AsyncCallChain.h" 8 #include "platform/v8_inspector/AsyncCallChain.h"
9 #include "platform/v8_inspector/IgnoreExceptionsScope.h" 9 #include "platform/v8_inspector/IgnoreExceptionsScope.h"
10 #include "platform/v8_inspector/InjectedScript.h" 10 #include "platform/v8_inspector/InjectedScript.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(breakp ointId, script.key, breakpoint, UserBreakpointSource); 355 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(breakp ointId, script.key, breakpoint, UserBreakpointSource);
356 if (location) 356 if (location)
357 (*locations)->addItem(location.release()); 357 (*locations)->addItem(location.release());
358 } 358 }
359 359
360 *outBreakpointId = breakpointId; 360 *outBreakpointId = breakpointId;
361 } 361 }
362 362
363 static bool parseLocation(ErrorString* errorString, PassOwnPtr<protocol::Debugge r::Location> location, String* scriptId, int* lineNumber, int* columnNumber) 363 static bool parseLocation(ErrorString* errorString, PassOwnPtr<protocol::Debugge r::Location> location, String* scriptId, int* lineNumber, int* columnNumber)
364 { 364 {
365 if (!location->hasScriptId() || !location->hasLineNumber()) {
366 // FIXME: replace with input validation.
367 *errorString = "scriptId and lineNumber are required.";
368 return false;
369 }
370 *scriptId = location->getScriptId(); 365 *scriptId = location->getScriptId();
371 *lineNumber = location->getLineNumber(); 366 *lineNumber = location->getLineNumber();
372 *columnNumber = location->getColumnNumber(0); 367 *columnNumber = location->getColumnNumber(0);
373 return true; 368 return true;
374 } 369 }
375 370
376 void V8DebuggerAgentImpl::setBreakpoint(ErrorString* errorString, 371 void V8DebuggerAgentImpl::setBreakpoint(ErrorString* errorString,
377 PassOwnPtr<protocol::Debugger::Location> location, 372 PassOwnPtr<protocol::Debugger::Location> location,
378 const Maybe<String>& optionalCondition, 373 const Maybe<String>& optionalCondition,
379 BreakpointId* outBreakpointId, 374 BreakpointId* outBreakpointId,
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 return; 1255 return;
1261 } 1256 }
1262 1257
1263 if (!inPositions->length()) { 1258 if (!inPositions->length()) {
1264 m_blackboxedPositions.remove(scriptId); 1259 m_blackboxedPositions.remove(scriptId);
1265 return; 1260 return;
1266 } 1261 }
1267 1262
1268 Vector<std::pair<int, int>> positions(inPositions->length()); 1263 Vector<std::pair<int, int>> positions(inPositions->length());
1269 for (size_t i = 0; i < positions.size(); ++i) { 1264 for (size_t i = 0; i < positions.size(); ++i) {
1270 OwnPtr<protocol::Debugger::ScriptPosition> position = inPositions->get(i ); 1265 protocol::Debugger::ScriptPosition* position = inPositions->get(i);
1271 if (!position->hasLine() || position->getLine() < 0) { 1266 if (position->getLine() < 0) {
1272 *error = "Position missing 'line' or 'line' < 0."; 1267 *error = "Position missing 'line' or 'line' < 0.";
1273 return; 1268 return;
1274 } 1269 }
1275 if (!position->hasColumn() || position->getColumn() < 0) { 1270 if (position->getColumn() < 0) {
1276 *error = "Position missing 'column' or 'column' < 0."; 1271 *error = "Position missing 'column' or 'column' < 0.";
1277 return; 1272 return;
1278 } 1273 }
1279 positions[i] = std::make_pair(position->getLine(), position->getColumn() ); 1274 positions[i] = std::make_pair(position->getLine(), position->getColumn() );
1280 } 1275 }
1281 1276
1282 for (size_t i = 1; i < positions.size(); ++i) { 1277 for (size_t i = 1; i < positions.size(); ++i) {
1283 if (positions[i - 1].first < positions[i].first) 1278 if (positions[i - 1].first < positions[i].first)
1284 continue; 1279 continue;
1285 if (positions[i - 1].first == positions[i].first && positions[i - 1].sec ond < positions[i].second) 1280 if (positions[i - 1].first == positions[i].first && positions[i - 1].sec ond < positions[i].second)
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 ASSERT(m_pausedContext.IsEmpty()); 1495 ASSERT(m_pausedContext.IsEmpty());
1501 m_pausedContext.Reset(m_isolate, context); 1496 m_pausedContext.Reset(m_isolate, context);
1502 m_currentCallStack.Reset(m_isolate, callFrames); 1497 m_currentCallStack.Reset(m_isolate, callFrames);
1503 v8::HandleScope handles(m_isolate); 1498 v8::HandleScope handles(m_isolate);
1504 1499
1505 if (!exception.IsEmpty()) { 1500 if (!exception.IsEmpty()) {
1506 InjectedScript* injectedScript = m_injectedScriptManager->injectedScript For(context); 1501 InjectedScript* injectedScript = m_injectedScriptManager->injectedScript For(context);
1507 if (injectedScript) { 1502 if (injectedScript) {
1508 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; 1503 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception;
1509 auto obj = injectedScript->wrapObject(exception, V8DebuggerAgentImpl ::backtraceObjectGroup); 1504 auto obj = injectedScript->wrapObject(exception, V8DebuggerAgentImpl ::backtraceObjectGroup);
1510 m_breakAuxData = obj ? obj->asValue() : nullptr; 1505 m_breakAuxData = obj ? obj->serialize() : nullptr;
1511 // m_breakAuxData might be null after this. 1506 // m_breakAuxData might be null after this.
1512 } 1507 }
1513 } else if (m_pausingOnAsyncOperation) { 1508 } else if (m_pausingOnAsyncOperation) {
1514 m_breakReason = protocol::Debugger::Paused::ReasonEnum::AsyncOperation; 1509 m_breakReason = protocol::Debugger::Paused::ReasonEnum::AsyncOperation;
1515 m_breakAuxData = JSONObject::create(); 1510 m_breakAuxData = JSONObject::create();
1516 m_breakAuxData->setNumber("operationId", m_currentAsyncOperationId); 1511 m_breakAuxData->setNumber("operationId", m_currentAsyncOperationId);
1517 } 1512 }
1518 1513
1519 OwnPtr<Array<String>> hitBreakpointIds = Array<String>::create(); 1514 OwnPtr<Array<String>> hitBreakpointIds = Array<String>::create();
1520 1515
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 m_scripts.clear(); 1618 m_scripts.clear();
1624 m_blackboxedPositions.clear(); 1619 m_blackboxedPositions.clear();
1625 m_breakpointIdToDebuggerBreakpointIds.clear(); 1620 m_breakpointIdToDebuggerBreakpointIds.clear();
1626 resetAsyncCallTracker(); 1621 resetAsyncCallTracker();
1627 m_promiseTracker->clear(); 1622 m_promiseTracker->clear();
1628 if (m_frontend) 1623 if (m_frontend)
1629 m_frontend->globalObjectCleared(); 1624 m_frontend->globalObjectCleared();
1630 } 1625 }
1631 1626
1632 } // namespace blink 1627 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698