Added kibana (#2286)
Browse filesAdded kibana to make elastic management easier.
PR #1710 did this.
PR #1714 revert this.
This PR did again and fix some bugs.
- [x] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
- README.md +1 -1
- README_ko.md +1 -1
- README_zh.md +1 -1
- SECURITY.md +1 -1
- docker/docker-compose-admin-tool.yml +5 -1
- docker/entrypoint.sh +3 -0
- docker/init-kibana.sh +56 -19
README.md
CHANGED
|
@@ -192,7 +192,7 @@ Try our demo at [https://demo.ragflow.io](https://demo.ragflow.io).
|
|
| 192 |
* Running on http://x.x.x.x:9380
|
| 193 |
INFO:werkzeug:Press CTRL+C to quit
|
| 194 |
```
|
| 195 |
-
> If you skip this confirmation step and directly log in to RAGFlow, your browser may prompt a `network
|
| 196 |
|
| 197 |
5. In your web browser, enter the IP address of your server and log in to RAGFlow.
|
| 198 |
> With the default settings, you only need to enter `http://IP_OF_YOUR_MACHINE` (**sans** port number) as the default HTTP serving port `80` can be omitted when using the default configurations.
|
|
|
|
| 192 |
* Running on http://x.x.x.x:9380
|
| 193 |
INFO:werkzeug:Press CTRL+C to quit
|
| 194 |
```
|
| 195 |
+
> If you skip this confirmation step and directly log in to RAGFlow, your browser may prompt a `network abnormal` error because, at that moment, your RAGFlow may not be fully initialized.
|
| 196 |
|
| 197 |
5. In your web browser, enter the IP address of your server and log in to RAGFlow.
|
| 198 |
> With the default settings, you only need to enter `http://IP_OF_YOUR_MACHINE` (**sans** port number) as the default HTTP serving port `80` can be omitted when using the default configurations.
|
README_ko.md
CHANGED
|
@@ -178,7 +178,7 @@
|
|
| 178 |
* Running on http://x.x.x.x:9380
|
| 179 |
INFO:werkzeug:Press CTRL+C to quit
|
| 180 |
```
|
| 181 |
-
> 만약 확인 단계를 건너뛰고 바로 RAGFlow에 로그인하면, RAGFlow가 완전히 초기화되지 않았기 때문에 브라우저에서 `network
|
| 182 |
|
| 183 |
5. 웹 브라우저에 서버의 IP 주소를 입력하고 RAGFlow에 로그인하세요.
|
| 184 |
> 기본 설정을 사용할 경우, `http://IP_OF_YOUR_MACHINE`만 입력하면 됩니다 (포트 번호는 제외). 기본 HTTP 서비스 포트 `80`은 기본 구성으로 사용할 때 생략할 수 있습니다.
|
|
|
|
| 178 |
* Running on http://x.x.x.x:9380
|
| 179 |
INFO:werkzeug:Press CTRL+C to quit
|
| 180 |
```
|
| 181 |
+
> 만약 확인 단계를 건너뛰고 바로 RAGFlow에 로그인하면, RAGFlow가 완전히 초기화되지 않았기 때문에 브라우저에서 `network abnormal` 오류가 발생할 수 있습니다.
|
| 182 |
|
| 183 |
5. 웹 브라우저에 서버의 IP 주소를 입력하고 RAGFlow에 로그인하세요.
|
| 184 |
> 기본 설정을 사용할 경우, `http://IP_OF_YOUR_MACHINE`만 입력하면 됩니다 (포트 번호는 제외). 기본 HTTP 서비스 포트 `80`은 기본 구성으로 사용할 때 생략할 수 있습니다.
|
README_zh.md
CHANGED
|
@@ -167,7 +167,7 @@
|
|
| 167 |
* Running on http://x.x.x.x:9380
|
| 168 |
INFO:werkzeug:Press CTRL+C to quit
|
| 169 |
```
|
| 170 |
-
> 如果您跳过这一步系统确认步骤就登录 RAGFlow,你的浏览器有可能会提示 `network
|
| 171 |
|
| 172 |
5. 在你的浏览器中输入你的服务器对应的 IP 地址并登录 RAGFlow。
|
| 173 |
> 上面这个例子中,您只需输入 http://IP_OF_YOUR_MACHINE 即可:未改动过配置则无需输入端口(默认的 HTTP 服务端口 80)。
|
|
|
|
| 167 |
* Running on http://x.x.x.x:9380
|
| 168 |
INFO:werkzeug:Press CTRL+C to quit
|
| 169 |
```
|
| 170 |
+
> 如果您跳过这一步系统确认步骤就登录 RAGFlow,你的浏览器有可能会提示 `network abnormal` 或 `网络异常`,因为 RAGFlow 可能并未完全启动成功。
|
| 171 |
|
| 172 |
5. 在你的浏览器中输入你的服务器对应的 IP 地址并登录 RAGFlow。
|
| 173 |
> 上面这个例子中,您只需输入 http://IP_OF_YOUR_MACHINE 即可:未改动过配置则无需输入端口(默认的 HTTP 服务端口 80)。
|
SECURITY.md
CHANGED
|
@@ -18,7 +18,7 @@ main
|
|
| 18 |
### Actual behavior
|
| 19 |
|
| 20 |
The restricted_loads function at [api/utils/__init__.py#L215](https://github.com/infiniflow/ragflow/blob/main/api/utils/__init__.py#L215) is still vulnerable leading via code execution.
|
| 21 |
-
The main
|
| 22 |
|
| 23 |
|
| 24 |
### Steps to reproduce
|
|
|
|
| 18 |
### Actual behavior
|
| 19 |
|
| 20 |
The restricted_loads function at [api/utils/__init__.py#L215](https://github.com/infiniflow/ragflow/blob/main/api/utils/__init__.py#L215) is still vulnerable leading via code execution.
|
| 21 |
+
The main reason is that numpy module has a numpy.f2py.diagnose.run_command function directly execute commands, but the restricted_loads function allows users import functions in module numpy.
|
| 22 |
|
| 23 |
|
| 24 |
### Steps to reproduce
|
docker/docker-compose-admin-tool.yml
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
services:
|
| 2 |
kibana:
|
| 3 |
image: kibana:${STACK_VERSION}
|
|
@@ -12,7 +16,7 @@ services:
|
|
| 12 |
es01:
|
| 13 |
condition: service_healthy
|
| 14 |
kibana-user-init:
|
| 15 |
-
condition: service_completed_successfully
|
| 16 |
|
| 17 |
networks:
|
| 18 |
- ragflow
|
|
|
|
| 1 |
+
include:
|
| 2 |
+
- path: ./docker-compose.yml
|
| 3 |
+
env_file: ./.env
|
| 4 |
+
|
| 5 |
services:
|
| 6 |
kibana:
|
| 7 |
image: kibana:${STACK_VERSION}
|
|
|
|
| 16 |
es01:
|
| 17 |
condition: service_healthy
|
| 18 |
kibana-user-init:
|
| 19 |
+
condition: service_completed_successfully
|
| 20 |
|
| 21 |
networks:
|
| 22 |
- ragflow
|
docker/entrypoint.sh
CHANGED
|
@@ -1,5 +1,8 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
|
|
|
|
|
|
|
|
|
| 3 |
/usr/sbin/nginx
|
| 4 |
|
| 5 |
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
+
# unset http proxy which maybe set by docker daemon
|
| 4 |
+
export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
|
| 5 |
+
|
| 6 |
/usr/sbin/nginx
|
| 7 |
|
| 8 |
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/
|
docker/init-kibana.sh
CHANGED
|
@@ -1,30 +1,67 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
| 5 |
-
echo "等待 Elasticsearch 啟動..."
|
| 6 |
-
sleep 5
|
| 7 |
-
done
|
| 8 |
|
|
|
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
PAYLOAD="{
|
| 15 |
-
\"password\" : \"${KIBANA_PASSWORD}\",
|
| 16 |
-
\"roles\" : [ \"kibana_admin\",\"kibana_system\" ],
|
| 17 |
-
\"full_name\" : \"${KIBANA_USER}\",
|
| 18 |
-
\"email\" : \"${KIBANA_USER}@example.com\"
|
| 19 |
-
}"
|
| 20 |
-
echo "新用戶帳戶: $PAYLOAD"
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
-d "$PAYLOAD"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
echo "
|
|
|
|
|
|
|
| 29 |
|
| 30 |
exit 0
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
+
# unset http proxy which maybe set by docker daemon
|
| 4 |
+
export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
echo "Elasticsearch built-in user: elastic:${ELASTIC_PASSWORD}"
|
| 7 |
|
| 8 |
+
# Wait Elasticsearch be healthy
|
| 9 |
+
while true; do
|
| 10 |
+
response=$(curl -s -v -w "\n%{http_code}" -u "elastic:${ELASTIC_PASSWORD}" "http://es01:9200")
|
| 11 |
+
exit_code=$?
|
| 12 |
+
status=$(echo "$response" | tail -n1)
|
| 13 |
+
if [ $exit_code -eq 0 ] && [ "$status" = "200" ]; then
|
| 14 |
+
echo "Elasticsearch is healthy"
|
| 15 |
+
break
|
| 16 |
+
else
|
| 17 |
+
echo "Elasticsearch is unhealthy: $exit_code $status"
|
| 18 |
+
echo "$response"
|
| 19 |
+
sleep 5
|
| 20 |
+
fi
|
| 21 |
+
done
|
| 22 |
|
| 23 |
+
# Create new role with all privileges to all indices
|
| 24 |
+
# https://www.elastic.co/guide/en/elasticsearch/reference/current/security-privileges.html#privileges-list-indices
|
| 25 |
+
echo "Going to create Elasticsearch role own_indices with all privileges to all indices"
|
| 26 |
+
while true; do
|
| 27 |
+
response=$(curl -s -v -w "\n%{http_code}" -u "elastic:${ELASTIC_PASSWORD}" -X POST http://es01:9200/_security/role/own_indices -H 'Content-Type: application/json' -d '{"indices": [{"names": ["*"], "privileges": ["all"]}]}')
|
| 28 |
+
exit_code=$?
|
| 29 |
+
status=$(echo "$response" | tail -n1)
|
| 30 |
+
if [ $exit_code -eq 0 ] && [ "$status" = "200" ]; then
|
| 31 |
+
echo "Elasticsearch role own_indices created"
|
| 32 |
+
break
|
| 33 |
+
else
|
| 34 |
+
echo "Elasticsearch role own_indices failure: $exit_code $status"
|
| 35 |
+
echo "$response"
|
| 36 |
+
sleep 5
|
| 37 |
+
fi
|
| 38 |
+
done
|
| 39 |
|
| 40 |
+
echo "Elasticsearch role own_indices:"
|
| 41 |
+
curl -u "elastic:${ELASTIC_PASSWORD}" -X GET "http://es01:9200/_security/role/own_indices"
|
| 42 |
+
echo ""
|
| 43 |
|
| 44 |
+
PAYLOAD="{\"password\": \"${KIBANA_PASSWORD}\", \"roles\": [\"kibana_admin\", \"kibana_system\", \"own_indices\"], \"full_name\": \"${KIBANA_USER}\", \"email\": \"${KIBANA_USER}@example.com\"}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
echo "Going to create Elasticsearch user ${KIBANA_USER}: ${PAYLOAD}"
|
| 47 |
+
|
| 48 |
+
# Create new user
|
| 49 |
+
while true; do
|
| 50 |
+
response=$(curl -s -v -w "\n%{http_code}" -u "elastic:${ELASTIC_PASSWORD}" -X POST http://es01:9200/_security/user/${KIBANA_USER} -H "Content-Type: application/json" -d "${PAYLOAD}")
|
| 51 |
+
exit_code=$?
|
| 52 |
+
status=$(echo "$response" | tail -n1)
|
| 53 |
+
if [ $exit_code -eq 0 ] && [ "$status" = "200" ]; then
|
| 54 |
+
echo "Elasticsearch user ${KIBANA_USER} created"
|
| 55 |
+
break
|
| 56 |
+
else
|
| 57 |
+
echo "Elasticsearch user ${KIBANA_USER} failure: $exit_code $status"
|
| 58 |
+
echo "$response"
|
| 59 |
+
sleep 5
|
| 60 |
+
fi
|
| 61 |
+
done
|
| 62 |
|
| 63 |
+
echo "Elasticsearch user ${KIBANA_USER}:"
|
| 64 |
+
curl -u "elastic:${ELASTIC_PASSWORD}" -X GET "http://es01:9200/_security/user/${KIBANA_USER}"
|
| 65 |
+
echo ""
|
| 66 |
|
| 67 |
exit 0
|