Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

on:
push:
branches: [ "main" ]
branches: [ "main", "staging" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "staging" ]

permissions:
contents: read
Expand All @@ -19,15 +19,16 @@

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
- name: Install uv
uses: astral-sh/setup-uv@v4

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Python application' step
Uses Step
uses 'astral-sh/setup-uv' with ref 'v4', not a pinned commit hash
Comment on lines +22 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Pin the action to a specific commit hash for supply chain security.

Using astral-sh/setup-uv@v4 with just a version tag allows the action maintainer to push changes that could affect your CI without your knowledge. Pinning to a specific commit hash provides better security.

🔎 Proposed fix
     - name: Install uv
-      uses: astral-sh/setup-uv@v4
+      uses: astral-sh/setup-uv@v4  # pin to commit hash after verifying

To get the current commit hash for v4, run:

#!/bin/bash
# Get the latest commit hash for the v4 tag
curl -s https://api.github.com/repos/astral-sh/setup-uv/git/refs/tags/v4 | jq -r '.object.sha'

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 23-23: Unpinned tag for a non-immutable Action in workflow
Unpinned 3rd party Action 'Python application' step Uses Step uses 'astral-sh/setup-uv' with ref 'v4', not a pinned commit hash

🤖 Prompt for AI Agents
In @.github/workflows/python-app.yml around lines 22 - 23, Update the GitHub
Actions step named "Install uv" to pin the astral-sh/setup-uv action to a
specific commit SHA instead of the floating tag; replace the uses value
"astral-sh/setup-uv@v4" with "astral-sh/setup-uv@<commit-sha>" where
<commit-sha> is the full commit hash for the v4 tag (obtainable via the
repository API or git) so the workflow references an immutable action version
for supply-chain security.

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
uv pip install --system flake8 pytest
uv pip install --system .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ docker run -p 6379:6379 -p 3000:3000 -it --rm falkordb/falkordb:latest

Create your own `.env` file from the `.env.template` file

### Install dependencies

Install project dependencies:

```bash
uv sync
```

Start the server:
```bash
flask --app api/index.py run --debug
uv run flask --app api/index.py run --debug
```

### Creating a graph
Expand Down
17 changes: 10 additions & 7 deletions api/analyzers/source_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,23 @@ def second_pass(self, graph: Graph, files: list[Path], path: Path) -> None:
logging.info(f'Processing file ({i + 1}/{files_len}): {file_path}')
for _, entity in file.entities.items():
entity.resolved_symbol(lambda key, symbol: analyzers[file_path.suffix].resolve_symbol(self.files, lsps[file_path.suffix], file_path, path, key, symbol))
for key, symbols in entity.resolved_symbols.items():
for key, symbols in entity.symbols.items():
for symbol in symbols:
if len(symbol.resolved_symbol) == 0:
continue
resolved_symbol = next(iter(symbol.resolved_symbol))
if key == "base_class":
graph.connect_entities("EXTENDS", entity.id, symbol.id)
graph.connect_entities("EXTENDS", entity.id, resolved_symbol.id)
elif key == "implement_interface":
graph.connect_entities("IMPLEMENTS", entity.id, symbol.id)
graph.connect_entities("IMPLEMENTS", entity.id, resolved_symbol.id)
elif key == "extend_interface":
graph.connect_entities("EXTENDS", entity.id, symbol.id)
graph.connect_entities("EXTENDS", entity.id, resolved_symbol.id)
elif key == "call":
graph.connect_entities("CALLS", entity.id, symbol.id)
graph.connect_entities("CALLS", entity.id, resolved_symbol.id, {"line": symbol.symbol.start_point.row, "text": symbol.symbol.text.decode("utf-8")})
elif key == "return_type":
graph.connect_entities("RETURNS", entity.id, symbol.id)
graph.connect_entities("RETURNS", entity.id, resolved_symbol.id)
elif key == "parameters":
graph.connect_entities("PARAMETERS", entity.id, symbol.id)
graph.connect_entities("PARAMETERS", entity.id, resolved_symbol.id)

def analyze_files(self, files: list[Path], path: Path, graph: Graph) -> None:
self.first_pass(path, files, [], graph)
Expand Down
22 changes: 11 additions & 11 deletions api/entities/entity.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
from typing import Callable, Self
from tree_sitter import Node

class Symbol:
def __init__(self, symbol: Node):
self.symbol = symbol
self.resolved_symbol = set()

def add_resolve_symbol(self, resolved_symbol):
self.resolved_symbol.add(resolved_symbol)

class Entity:
def __init__(self, node: Node):
self.node = node
self.symbols: dict[str, list[Node]] = {}
self.resolved_symbols: dict[str, set[Self]] = {}
self.symbols: dict[str, list[Symbol]] = {}
self.children: dict[Node, Self] = {}

def add_symbol(self, key: str, symbol: Node):
if key not in self.symbols:
self.symbols[key] = []
self.symbols[key].append(symbol)

def add_resolved_symbol(self, key: str, symbol: Self):
if key not in self.resolved_symbols:
self.resolved_symbols[key] = set()
self.resolved_symbols[key].add(symbol)
self.symbols[key].append(Symbol(symbol))

def add_child(self, child: Self):
child.parent = self
self.children[child.node] = child

def resolved_symbol(self, f: Callable[[str, Node], list[Self]]):
for key, symbols in self.symbols.items():
self.resolved_symbols[key] = set()
for symbol in symbols:
for resolved_symbol in f(key, symbol):
self.resolved_symbols[key].add(resolved_symbol)
for resolved_symbol in f(key, symbol.symbol):
symbol.add_resolve_symbol(resolved_symbol)
5 changes: 3 additions & 2 deletions api/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def set_file_coverage(self, path: str, name: str, ext: str, coverage: float) ->

res = self._query(q, params)

def connect_entities(self, relation: str, src_id: int, dest_id: int) -> None:
def connect_entities(self, relation: str, src_id: int, dest_id: int, properties: dict = {}) -> None:
"""
Establish a relationship between src and dest

Expand All @@ -491,9 +491,10 @@ def connect_entities(self, relation: str, src_id: int, dest_id: int) -> None:
q = f"""MATCH (src), (dest)
WHERE ID(src) = $src_id AND ID(dest) = $dest_id
MERGE (src)-[e:{relation}]->(dest)
SET e += $properties
RETURN e"""

params = {'src_id': src_id, 'dest_id': dest_id}
params = {'src_id': src_id, 'dest_id': dest_id, "properties": properties}
self._query(q, params)

def function_calls_function(self, caller_id: int, callee_id: int, pos: int) -> None:
Expand Down
2 changes: 0 additions & 2 deletions api/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@ def _define_ontology() -> Ontology:
ontology = _define_ontology()

def _create_kg_agent(repo_name: str):
global ontology

model_name = os.getenv('MODEL_NAME', 'gemini/gemini-2.0-flash')

model = LiteModel(model_name)
Expand Down
Loading
Loading