4 Commits

Author SHA1 Message Date
Hrushikesh Deshpande
802a3e5031 Update semgrep.yml 2024-09-25 18:35:54 -04:00
hrushikeshdeshpande
65af6addd8 Update semgrep.yml
Updating Semgrep.yml file - Semgrep is a tool that will be used to scan Cloudflare's public repos for Supply chain, code and secrets. This work is part of Application & Product Security team's initiative to onboard Semgrep onto all of Cloudflare's public repos.

In case of any questions, please reach out to "Hrushikesh Deshpande" on cf internal chat.
2024-09-21 13:09:14 -04:00
Hrushikesh Deshpande
fd7c520f1a Adding semgrep yaml file 2024-09-19 21:52:53 -04:00
Louis Poinsignon
ec5e6b64ee Added license 2018-08-09 08:42:13 -07:00
4 changed files with 55 additions and 24 deletions

24
.github/workflows/semgrep.yml vendored Normal file
View File

@@ -0,0 +1,24 @@
on:
pull_request: {}
workflow_dispatch: {}
push:
branches:
- main
- master
schedule:
- cron: '0 0 * * *'
name: Semgrep config
jobs:
semgrep:
name: semgrep/ci
runs-on: ubuntu-latest
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
SEMGREP_URL: https://cloudflare.semgrep.dev
SEMGREP_APP_URL: https://cloudflare.semgrep.dev
SEMGREP_VERSION_CHECK_URL: https://cloudflare.semgrep.dev/api/check-version
container:
image: semgrep/semgrep
steps:
- uses: actions/checkout@v4
- run: semgrep ci

11
LICENSE.txt Normal file
View File

@@ -0,0 +1,11 @@
Copyright (c) 2018, Cloudflare. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -780,35 +780,32 @@ func DecodeBGP4TD2(buf io.Reader, timestamp time.Time, subtype uint16, length ui
return nil, nil
}
type mrtBinaryHeader struct {
Timestamp uint32
Mrttype uint16
Mrtsubtype uint16
Mrtlength uint32
}
func DecodeSingle(buf io.Reader) (Mrt, error) {
hdr := mrtBinaryHeader{}
var timestamp uint32
var mrttype uint16
var mrtsubtype uint16
var mrtlength uint32
e := binary.Read(buf, binary.BigEndian, &hdr)
if e != nil { return nil, e }
binary.Read(buf, binary.BigEndian, &timestamp)
binary.Read(buf, binary.BigEndian, &mrttype)
binary.Read(buf, binary.BigEndian, &mrtsubtype)
binary.Read(buf, binary.BigEndian, &mrtlength)
timestampP := time.Unix(int64(hdr.Timestamp), 0)
timestampP := time.Unix(int64(timestamp), 0)
content := make([]byte, hdr.Mrtlength)
e = binary.Read(buf, binary.BigEndian, &content)
if e != nil { return nil, e }
content := make([]byte, mrtlength)
binary.Read(buf, binary.BigEndian, &content)
tmpbuf := bytes.NewBuffer(content)
var mrt Mrt
var err error
switch hdr.Mrttype {
switch mrttype {
case TYPE_BGP4MP:
mrt, err = DecodeBGP4MP(tmpbuf, timestampP, hdr.Mrtsubtype, hdr.Mrtlength)
mrt, err = DecodeBGP4MP(tmpbuf, timestampP, mrtsubtype, mrtlength)
case TYPE_TABLE_DUMPV2:
mrt, err = DecodeBGP4TD2(tmpbuf, timestampP, hdr.Mrtsubtype, hdr.Mrtlength)
mrt, err = DecodeBGP4TD2(tmpbuf, timestampP, mrtsubtype, mrtlength)
default:
err = errors.New(fmt.Sprintf("Decoding of type %v not implemented", hdr.Mrttype))
err = errors.New(fmt.Sprintf("Decoding of type %v not implemented", mrttype))
}
return mrt, err

View File

@@ -197,25 +197,24 @@ func (n *Neighbor) Connect() error {
func (n *Neighbor) Disconnect() {
log.Infof("%v: Disconnected", n.String())
wasConnected := n.Connected
n.Connected = false
n.State.OpenReceived = false
n.tcpconn.Close()
n.UpdateState(STATE_IDLE)
if n.HandlerEvent != nil && wasConnected == true {
if n.HandlerEvent != nil {
n.HandlerEvent.DisconnectedNeighbor(n)
}
if n.RemoveOnDisconnect && n.s != nil && n.s.Manager != nil {
log.Infof("%v: Removing from manager", n.String())
select {
case n.qLife <- true:
default:
case n.qLife <- true:
default:
}
select {
case n.qSender <- true:
default:
case n.qSender <- true:
default:
}
n.s.Manager.RemoveNeighbor(n)