
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
github.com/travissimon/go-mvc
Go-MVC is a lightweight MVC framework for the Go language. Its goals are to provide an efficient, testable framework for creating web applications.
Go-MVC's main features are:
Development is still underway, so contributions are encouraged.
Go-MVC lets you create routes with named parameters. For example, you can create a route as follows:
mvcHandle := mvc.NewMvcHandler()
mvcHandle.AddRoute("Hello", "/Hello/{name}", mvc.GET, GreetingController)
http.Handle("/", mvcHandle)
http.ListenAndServe("localhost:8080", nil)
The code above creates a route named 'Hello' that intercepts GET requests for routes that match 'localhost:8080/Hello/*' and directs them to a controller named 'GreetingController'.
Controller methods accept a parameter called 'params' which contains query string parameters, form post parameters and values from named routes. You can then access the values inside of your controller. For example, if a request is made to 'http://localhost:8080/Hello/World', you could access the value of 'name' as follows:
name := params.Get("name")
Go-MVC provides a clean separation between controller logic and view presentation, allowing for easy testing. For example, the following controller converts a URL part (specified in a route: see below) to uppercase:
func ToUpperController(ctx *mvc.WebContext, params url.Values) mvc.ControllerResults {
in := params.Get("input")
upper := strings.ToUpper(in)
hamlWriter := NewViewWriter(upper)
return mvc.Haml(hamlWriter, upper, ctx)
}
The code above could be tested like this:
func ToUpperController_Test(t *testing.T) {
ctx, params = GetTestControllerParameters()
params.Add("input", "tesTIng")
result := ToUpperController(ctx, params)
hamlRes := res.(*HamlResult)
if hamlRes.Data != "TESTING" {
t.Error("Data not as expected: " + hamlRes.Data)
}
}
Go-MVC provides server-side sessions transparently. As a developer you just add and remove items from the session:
var val interface{}
if val, exists = ctx.Session.Get("count"); !exists {
val = -1
}
count := val.(int)
count++
ctx.Session.Put("count", count)
Copyright 2013 Travis Simon
Licensed under the GNU General Public License Version 2.0 (or later); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.